Created
December 12, 2012 03:15
-
-
Save DavidWells/4264582 to your computer and use it in GitHub Desktop.
jquery to add hover elements to every item on the page
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
$(document).ready(function() { | |
$('head').append('<style type="text/css">.outline-element {outline: 1px solid #c00;}.outline-element-clicked {outline: 1px solid #0c0;}</style>'); | |
$('body').bind('mouseover mouseout click', function(event) { | |
var $tgt = $(event.target); | |
if (!$tgt.closest('.syntax_hilite').length) { | |
$tgt.toggleClass(event.type == 'click' ? 'outline-element-clicked' : 'outline-element'); | |
$('body').removeClass('outline-element-clicked') | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment