You can use the simple addEventlistener as follow:
<!DOCTYPE html>
<html>
<body>
<p>This example uses the addEventListener() method to attach a click event to a button.</p>
<button id="myBtn">Try it</button>
<p id="demo">Hello</p>
<script>
document.getElementById("myBtn").addEventListener("click", function() {
document.getElementById("demo").innerHTML = " ";
});
</script>
</body>
</html>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…