[ACCEPTED]-jQuery click() event not firing on AJAX loaded HTML elements-ajax
Do this.
$(document).on("click",".sframe",function(e){
var seat_number = this.id.match(/\d/g);
alert(seat_number);
});
or
$(document).delegate(".sframe","click",function(e){
var seat_number = this.id.match(/\d/g);
alert(seat_number);
});
Edit:
As of jQuery 1.7, the .live() method is deprecated. Use .on() to attach event handlers. Users of older versions of jQuery should use .delegate().
0
you have to re-attach the event handlers 5 to the dynamically added elements into the 4 DOM. .live
method was used widely but now its 3 deprecated. In jQuery version 1.7+ you can 2 use .on
or alternatively you can use .delegate
$(document).on("click",".sframe",function(e){
});
using 1 delegate
$(document).delegate(".sframe","click",function(e){
});
Unless you are calling that .bind() function 8 after that markup is loaded onto the page, you 7 need to use another function like .live() or 6 preferably if using a recent version of 5 jQuery, .on() because .bind() only targets 4 DOM elements already present when run whereas 3 .live() and .on() give you different scope 2 options for keeping track of elements added 1 to the page.
$(document).on('click','sframe', function() {
var seat_number = this.id.match(/\d/g);
alert(seat_number);
});
0
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.