Start learning with our library of video tutorials taught by experts. Get started
Viewers: in countries Watching now:
Tooltips can greatly improve the usability of your web site by providing direction and cues to visitors. In this course, Chris Converse shows how to convert text or graphics into a mouse-sensitive tooltip. The tutorials demonstrate how to write the necessary HTML and activate the tooltip with jQuery, as well as add positioning and effects.
So after the beginning parentheses, let's put in a beginning bracket, get your cursor before the ending parentheses, and put in an ending bracket, and then we'll come back and change that comma to a colon. So the first property we're setting is display, let's hit a comma, two more tick marks for another string literal, let's put opacity, outside of the string literal, colon 0. So what we're doing here is in addition to setting the display to 'block,' so that it actually shows up in the page, we're setting the transparency to 0, so we can't see it yet.
Then outside of the parentheses for CSS and before the semicolon, we're going to add another jQuery statement, .animate, beginning and ending parentheses. Inside of the parentheses we'll add a beginning and ending bracket. Inside of the brackets we want to animate the opacity setting, so we'll type opacity:1, then outside of the brackets but still inside of the parentheses, comma 250 milliseconds. So on mouseover we're going to set the display to block, set the opacity to 0, and then animate the opacity up to 1 or 100% over the course of one quarter of the second.
So this function here is referred to as a callback function. So what this means is after the animation happens over 250 milliseconds, anything we put inside of here will then be executed. So we're going to want to come down here and cut this line that sets the display to 'none,' come inside of this callback function and then paste that in here. So the display setting to none will not happen until after the tooltip animates back down to 0. So to test this, let's hit Save, make sure all your files are saved. Let's come back to our operating system and let's reload this in our browser.
So now inside the browser, I'll rollover a tooltip trigger, the tooltip fades in, moves with my mouse and then fades away when I move out, and this works for all of the tooltips on the screen. So that completes adding a tooltip into your website with jQuery. In the next movie, we'll talk about some CSS properties that may interfere with having elements track with the mouse and how you can correct for that.
There are currently no FAQs about Create a Tooltip with jQuery.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.