I have a set of elements which are loaded and hence injected dynamically into the DOM. I have a script which requires the elements to be fully loaded for it to work properly. Assume the following code:
$(".element").width();
Which if put into the $(document).ready()
works properly.
But my scenario is a little different, the element is dynamically loaded into the page; therefore, I need a load event on the $(".element")
which itself is loaded dynamically. Now:
$(".element").load()
doesn't work as it is not loaded in the page by default, I have used $("body").on("load", ".element", function(){...});
But to no avail, still it does nothing. What should I do now?
My Question: How should I bind a load event to an element which is created dynamically.