document addeventlistener click

JavaScript
 document.getElementById("myBtn").addEventListener("click", function(){
  document.getElementById("demo").innerHTML = "Hello World";
}); 
Source

Also in JavaScript: