I am trying to perform action on id created in javaScript i.e. 'hh'. But nothing happens when i am clicking on the button. Please correct where i am going wrong.
<script>
$(document).ready(function () {
$("button").click(function () {
alert(this.id); // or alert($(this).attr('id'));
});
$(".hh").click(function () {
alert("gggg");
});
$("#btn2").click(function () {
$("ol").append("<li> <button id='hh'>Appended item</button></li>");
});
});
</script>
<!DOCTYPE html>
<html>
<head>
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</head>
<body>
<ol>
</ol>
<button id="btn2">Append list item</button>
</body>
</html>
Thanks in advance.