I am loading an HTML file into another HTML file using the jQuery load() method:
$("#sidebar").load("templates/sidebar.html");
<div id="sidebar"></div>
I have some javascript I would like to run on the loaded HTML file. This script isn't working, I believe due to the fact that it is unable to see the new HTML at the time of it's execution. For example, this line of jQuery would be unable to see my class of menu that exists within sidebar.html.
$('.menu').css('left', '100');
Is there any way I can force the script to wait until my loaded HTML is rendered before executing?
.load()and that function will be called when the content has been added to the DOM.