I cant get an alert to trigger when a dynamicaly generated button is clicked?
The alert is not going to be the final function but was a test to make sure the trigger is working correctly.
I tried a "onclick" function as a trigger and used the id as a jquery trigger so not sure why it would not work, I will add a snippet below that shows what I mean.
any pointers would be much appreciated as I am sure it is something simple I am missing.
From the file that generates and displays the button(it displays ok)
var modOptsMsg = document.getElementById("modOptionsMessage").value + '<input type="button" id="removePost" onclick="removePost()" value="Remove Post"/>';
$("#modOptsShowMsg").empty().append(modOptsMsg);
Neither of these simple tests work js or jquery
function removePost(){
alert("alert");
}
$('#removePost').click(function(){
alert("alert");
});
Thanks in advance.