Answer the question
In order to leave comments, you need to log in
How to make js work in an element received by ajax?
I load a file with html markup in .html format into some div file,
while I have a button click handler, let's say alert is normal inside, I made two identical buttons, one is after the div, into which the new page is loaded, and the other is in diva.
The button that is outside the div correctly calls the handler, and the one that is in the div ignores the event.
It turns out that elements loaded with ajax are not so easily perceived by handlers, but why? How to make them understand them?
Answer the question
In order to leave comments, you need to log in
$(document).on('click', '.button', function() {
console.log('click');
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question