Last active
December 19, 2015 16:49
-
-
Save eddiejhong/5986720 to your computer and use it in GitHub Desktop.
This is useful in creating popup text when mousing over an element on a page. Only one line of html is required!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('body').on({ | |
mouseenter: function(e) { //the argument 'e' allows for the use of position tracking | |
$('#popup_text').css({ //using the position of the current target (element which is moused over), we can position the popup text using CSS | |
left: $(this).offset().left-130, | |
top: $(this).offset().top-5 | |
}); | |
}, | |
mouseleave: function(e) { //once the mouse has left the target element, the CSS moves the popup text out of view | |
$('#popup_text').css({ | |
left: -9999, | |
}); | |
} | |
},', .top3star'); // ".top3star" was the element that we were interested in placing popup text near | |
//Example of html: | |
//<div id="popup_text">This is popup text!</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment