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

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

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

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