Jqeury click event doesn’t work after append
1 min readAug 6, 2019
- as you understand , in Jquery code click event doesn’t work after appending code
- as below , this click event listener doesn’t work.
$( ".pop_btn" ).on( "click", function( event ) { getChecked();});
https://stackoverflow.com/a/18196235/8249747
- Note that it is important that the “thing that exists” is as low as you can possibly get it in the DOM for efficiency. For example, it is not preferable to put the selector on the ‘body’ or at the document level. Keep this in mind.
preferable -
$('.wrap').on('click', '.pop_btn', function(e) {not pregerable -
$(document).on('click', '.pop_btn', function(e) {