I have this script
Javascript:
$('#generateEditWindow').on('click', function () {
var $el = $(this);
var id = $el.data('id');
alert(id)
});
and this HTML:
<a id="generateEditWindow" data-id="10">
Click to show the data id
</a>
And this works, but only if the page loads with THIS HTML already as part of the page. I need this script to react to new elements that are added to the DOM after page load. When I generate the HTML you see here after the DOM has loaded this function will not fire.
I have put this function in a document ready function but that doesn’t seem to make sense nor work and have tried outside of document ready. I feel like I need to make this function to fire “on change” and have it listen for calls but I don’t even know the terminology to be able to google that correctly. Any help would be great, thanks community.