One button, when clicked, changes the html in the body tag, in which there is a new button. New button, when clicked, should give an alert message, but it is not.
I think it's probably the document.ready part, which needs to be reinitialized. But i don't know how to do that. Please check the code:
<!DOCTYPE html>
<html>
<head>
<title>Title For the Website</title>
<script src="js/jquery-2.1.4.min.js"></script>
</head>
<body>
<div id="bigbox">
<button id="idol">Idol</button>
</div>
<script>
$(document).ready(function(e){
$('#idol').click(function(event) {
console.log("success");
var x = '<button id="clickhere">Click Here!</button></div></div>';
$('#bigbox').html(x);
});
$('#clickhere').click(function(event) {
alert('This is working');
});
});
</script>
</body>
</html>
This is a cut down version of my code. In the original page, a button generates some html through an ajax call, and that html has a button to do another ajax call.