[Solved] How can we attach a jquery function to a div that has been appended after the page was loaded, without any event being triggered [closed]
[ad_1] Your code already works as is, you don’t need to do anything about the div not existing yet. http://jsfiddle.net/97GZb/ function toggleDiv(id){ $(“#” + id).toggle(); } setTimeout(function(){ $(“body”).append(“<div id=’defaultTab-28′>I’m the div!!!</div>”); },5000); with this html: <a href=”https://stackoverflow.com/questions/13980330/javascript:toggleDiv(“defaultTab-28′)”>Click me to toggle the div that will be appended in 5 seconds.</a> And to answer your comment: … Read more