event listener javascript

JavaScript
let element = document.getElementById("xyz");
//	Event Listener
element.addEventListener("click",  myFunction);

// Call Function On Click
function myFunction() {
  alert("Hello World!");
}  document.getElementById("myBtn").addEventListener("click", displayDate);  document.getElementById("myBtn").addEventListener("click", function(){
  document.getElementById("demo").innerHTML = "Hello World";
}); element.addEventListener("click", function(){ 
   element.innerText = "something"; 
});  var x = document.getElementById("myBtn");
if (x.addEventListener) {                    // For all major browsers, except IE 8 and earlier

    x.addEventListener("click", myFunction);
} else if (x.attachEvent) {                  // For IE 8 and earlier versions

    x.attachEvent("onclick", myFunction);
} const element = document.querySelector(".class__name");

element.addEventListener("click", () => {
	console.log("clicked element");
});
Source

Also in JavaScript: