javascript - How does the $html.appendTo($parentEl) work internally to allow listeners to be attached before the $html is in the DOM? -
i thought listeners can attached elements in dom. if element dynamically added need reattach listeners or attach listeners parent element (bubbling) in first place. when use .appendto()
can somehow attach listeners element not in dom , still works. how appendto
change things? making grave mistake using method regret later?
code:
var $html = $("<div class='someelnotindom'>random text</div>"); attachsomelisteners($html); // ex. click event listener etc. var $parentel = $(".someelementindom").eq(0); $html.appendto($parentel); // listeners work. why?
Comments
Post a Comment