Creating "onload" functionality in dynamic HTML

Using jquery ajax I populate the contents of an HTML div.

This new HTML data has javascript code (this part works correctly). However, this javascript also has

$(document).load(function() { ... });

This part does not work because the document is already loaded!

How should I do it?

+3
source share
2 answers

Nothing unusual is required. It seems that dynamically loaded javascript is executed after the browser analyzes the dynamic content.

0
source

Are you sure it will always be downloaded via AJAX? If so, why not just delete it $(document).load()?

0
source

Source: https://habr.com/ru/post/1789568/


All Articles