Home › Forums › JavaScript › jQuery doesn’t execute on div loaded with ajax › Re: jQuery doesn’t execute on div loaded with ajax
January 18, 2013 at 4:39 pm
#121407
Mottie
Member
I’m not sure what I can help with without seeing any of your code. So here’s an example.
If you have a div that has content loaded dynamically (using ajax), you can open an alert popup to elements with a class name of “alert” to that dynamic content using `delegate` (or `on` if you are using jQuery 1.7+) like this:
HTML
Javascript
$(function(){
// .on(‘click’, ‘.alert’, function(){
$(‘#dynamic-content’).delegate(‘.alert’, ‘click’, function(){
alert( $(this).html() );
});
});