Creating "onload" functionality in Dynamic HTML
Using jquery ajax I populate contents of a div with HTML.
This new HTML data has javascript code (this part works correctly). However this javascrip开发者_开发问答t also has
$(document).load(function() { ... });
This part does not work since document is already loaded!
How should I handle this?
Are you sure it's always going to be loaded via AJAX? If so, why not just remove the $(document).load()
altogether?
Nothing fancy is actually needed. It seems that dynamically loaded javascript is executed after the dynamic content is parsed by the browser.
精彩评论