javascript - Hover highlight child should not highlight parent -
i trying highlight element when hover on (adding class). have nested elements on page. want is, if hover on element, immediate element gets highlighted not parent ones.
here snippet
$("body *").hover(function (e) { $(this).addclass('test'); }, function () { $(this).removeclass('test'); });`
try
$(document).ready(function (){ $("body").mouseover(function (e){ $(e.target).addclass('test'); }).mouseout(function (e) { $(e.target).removeclass('test'); }); });
demo: fiddle
Comments
Post a Comment