This question has already been answered:
This code does not work on all elements:
$('body').click(function (event) { t=event.target||event.srcElement; alert(t.tagName); }); Need more reliable method
This question has already been answered:
This code does not work on all elements:
$('body').click(function (event) { t=event.target||event.srcElement; alert(t.tagName); }); Need more reliable method
A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .
Through .click () the element is already found in the DOM, and through .on () the jquery searches for the specified .b element with each click
element = $("<button class='b'>element</button>"); $('button').click(function() { $('body').append(element); }); $('body').on('click', '.b', function() { console.log('b click'); }); <script src="https://code.jquery.com/jquery-3.0.0.min.js"></script> <button>Создать элемент</button> .click() element is already found in the DOM. And through .on() jquery searches for the specified .b element with each click. - Mr. BlackSource: https://ru.stackoverflow.com/questions/543023/
All Articles
$(element).on('click', function (event) { ... });- Mr. Black