javascript - Why hover() does not working on added class using jquery? -
this question has answer here:
i'm trying delay animation, task i'm adding .startanimation class after 500 milliseconds animation.
html
<div class="layout">hover it</div> <div class="hoverdiv"></div> js
settimeout(function(){ $(".layout").addclass('startanimation'); }, 500); $('.hoverdiv').hide(); $('.startanimation').hover(function(){ $('.hoverdiv').show(); }); but problem hover() not working added class .startanimation working .layout class located on same div. checked .startanimation class adding after 500 milliseconds. can 1 guide me regarding issue can fix it. appreciate.
here reference demo
use event delegation mouseenter, mouseleave events.
$(document).on('mouseenter mouseleave', '.startanimation', function(){ $('.hoverdiv').toggle(); });
Comments
Post a Comment