My issue is that I want to set a click event dynamically. So imagine I have a button. Clicking that button shows a popup box.
In that box I have a text like this:
"Men in <span class='timelineplace-bulgaria'>Bulgaria</span>"
But the issue is that I don't have access to the button event. So I would like to set the click event with an regex like this:
$("[class*='timelineplace']").click(function () {
var object = $(this);
alert(object.attr("class").match(/timelineplace-(.*?)(?:\s+|$)/)[1]);
});
But yeah this only works when the popup box already existed when jQuery loading finished. So the issue is that the popup is dynamically loaded. And the click event is set when the site has finished the loadings.
So Is there a way to set a click event also at runtime to any regex matching class? Or do I really have to go to the button click event and set the onclick there.