I want to fire an action when there is change in html
content. Below code changes html content of myId
element, when click
on button, so there is change in html content of myId
now I want to fire another action say console.log("myalert")
.
<html>
<body>
<input type="button" id="buttonid" value="click">
<div id = "myId">
</div>
</body>
<script>
var button = document.getElementById("buttonid");
button.addEventListener("click", function () {
console.log("alert");
document.getElementById('myId').innerHTML = '<input type="button" id="button3" value="click2">'
});
var button2 = document.getElementById("myId");
button2.addEventListener("change", function () {
console.log("myalert");
});
</script>
</html>
How can I achieve my requirement?
Note: I don't want to use jQuery
.