I have a js function which calls 'generate.php' on click event. The php returns an anchor tag with id 'alert'. the js functions appends this anchor tag to the document. Another js function acts on this dynamically generated anchor. As title says the .on() function doesn't bind the event handler on this anchor tag.Please help me out...
My js file is as below
$("#generate").click(function(){ // Working Fine :)
$.post("generate.php",function(reply){
$("reply").html(reply);
}
});
$("#alert").on("click",function(){ //Not Working :(
alert("hello");
}
My html code is as below
<a href="#" id="generate">Click TO generate</a>
<div id = "reply"></div>
My generate.php looks like this
<?php //Working Fine
echo '<a href="#" id="alert">Click To get alert Box</a>';
echo '<div id="abc">Click The above link to get an alert</div>';
?>