Let's say that I have some HTML content in which I have some textareas. This HTML content is loaded through Ajax after performing some kind of action (like a button click or something). The problem that I have is that I lose all kinds of jQuery events that were bond to my textareas (like the .change
event or something, so if I do something like:
$('.my_textarea').change(function(){
alert('TEST');
});
My alert does not display because my textarea has been loaded with Ajax. Does anybody have any idea why this problem happens and how I can fix this?
Thanks in advance for any suggestions
$(document).on('change', '.my_textarea', function(){
alert('TEST');
});
Just replace document
with the closest static ( not loaded via Ajax ) parent of your textarea
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.