Jquery Event Not Working After Append
http://jsfiddle.net/YsnhT/2/ Jquery event on is not working after the append. I need the value of textarea after I click save button. $('.span8') .on('click', '.btn
Solution 1:
Since #save
is dynamically created, use the following handler:
$(document).on('click', '#save' ,function() {
//do stuff
});
Updated fiddle: http://jsfiddle.net/tymeJV/YsnhT/3/
You should also make your "click" button handler like this, or else it will not fire on newly created #click
buttons.
Solution 2:
Simply delegate the event in dynamic format:
$(document).on('click', '#save' ,function() {
//do stuff
})
And perhaps do the same for:
$(document).on('click', '#click' ,function() {
//do stuff
})
Solution 3:
save is creating dynamically here.So try to using on
$(document).on('click', '#save' ,function() {
});
Solution 4:
Once you have appended the element you need to rebind the handlers to it or use jQuery's live() function, like so:
$('.span8 .btn').live('click', function() {
var input = $("#textarea").val();
alert(input);
});
Solution 5:
check this...
$('.btn').click(function() {
var input = $("#textarea").val();
alert(input);
});
Post a Comment for "Jquery Event Not Working After Append"