Last active
November 21, 2022 18:20
-
-
Save codump/a1748630880c7ea1dd5500312b2743a2 to your computer and use it in GitHub Desktop.
On click dynamically created elements.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).on('click', '.addedElement', function(){ | |
alert('Clicked on dynamic added element'); // Change to function you want. | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When an element is dynamically created in the document/website the normal
$('.addedElement').click(function(e){
click function doesn't work. The snippet above will solve that issue for u. When clicked on any element, dynamically added or not, with the classaddedElement
it will run the function.