javascript - jQuery .hide() doesn't run on dynamically created elements -


this question has answer here:

i want dynamically create div elements in container. simple function:

function myfunction(volume){ for(var = 1; i<= volume; i++){ $('.container').append("<div></div>"); } 

the problem generated div elements not react jquery .hide() function. know why not working? html looks fine both manualy , dynamically created elements.

i did jsfiddle, kinda broken too: http://jsfiddle.net/gqben/

my call of .hide() function

$('div').mouseenter(function() { if (run){ $(this).hide(3000, function() { result++; run = false; rewrite(); }); } }); 

aron solve in comments: http://jsfiddle.net/arunpjohny/sm38c/1/ thanks!

you should use event delegation that

$(".container").on("mouseenter","div",function(e){  }); 

event delegation allows attach single event listener, parent element, fire children matching selector, whether children exist or added in future.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -