Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Now back in our HTML file, what we need to do here is add in those data attributes into the anchor link that's inside of the aside container. So let's scroll up here, let's find the aside container right here, inside there is an anchor link with a HTML-based tooltip link here. Let's come inside of the anchor tag, after the href attribute, hit space, we'll type data-tip-type, equals, two quotes. Inside of the quotes we'll put html, then we'll add another attribute, hit a space, data-tip-source, equals, two quotes, and instead of putting actual text here, what we're going to do is point to the id of the container we want to use.
So the second if statement is testing the actual item that's being rolled over to see if the attribute data-tip-type is set to HTML, and if it is, we're going to run these instructions inside of here. So let's get our cursor in front of the first statement, let's hit two Returns, and above that what we're going to do is declare a new variable, we're going to type var elementToGet. We're going to set this equal to, two tick marks for string literal and a pound sign. Outside of the string literal, we're going to type a plus sign and then we're going to type dollar sign, parentheses, this, outside of the parentheses .attr, beginning and ending parentheses, semicolon.
Inside of the parentheses, two tick marks for string literal, and we want to go out and get the data-tip-source. So what this does is it goes out to the item that's being rolled over and we're checking the attribute data-tip-source, which in this case is actually the name of the ID where we put all of the HTML we want to have injected. We're adding a hash symbol here and putting these together or concatenating this into this single URL. It is going to give us something similar to what we're doing up here, where we're using jQuery to find a specific ID.
So once we've defined our variable elementToGet, on the next line we're going to declare a second variable. We're going to call this one newHTML and we're going to set that equal to, and then we're going to type dollar sign, beginning and ending parentheses, and we want to get this element, so let's copy that variable name, let's paste it down here, outside of the parentheses we're going to type .html, beginning and ending parentheses, then a semicolon. So we're going to go get whatever ID is specified in that link, we're going to pull all the HTML into the newHTML variable, and then on this line we're going to keep the tooltip container HTML, but instead of setting it to the value of the data-tip-source, let's remove that, and let's come in here and copy the newHTML variable, and let's paste that in there instead.
Let's save our document. Let's come back out to the browser and let's say Reload. Now over in our browser, we can rollover the HTML base tooltip, and then we can see the contents of the tooltip are now changing to all of the HTML that we put inside of that ID. Then I can go back to the text-based one and see just the text that is actually being pulled from that source attribute. So now that we are properly querying every one of the tooltip items and detecting whether they are text or HTML and populating the tooltip container, in the next movie we can now start to work on attaching the tooltip to where the mouse is.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 98119 Viewers
61 Video lessons · 85424 Viewers
71 Video lessons · 69396 Viewers
56 Video lessons · 101755 Viewers
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.
Your file was successfully uploaded.