Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DavidWells/4264582 to your computer and use it in GitHub Desktop.
Save DavidWells/4264582 to your computer and use it in GitHub Desktop.
jquery to add hover elements to every item on the page
$(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