Javascript addEventListener() is a built in function which is used to add event listener to any HTML object like HTML document, window, object etc.
Basic syntax of Event Listener
Example
<!DOCTYPE html>
<html>
<body>
<button id="clickMe">Click Me</button>
<h1 id="content"></h1>
<script>
document.getElementById("clickMe").addEventListener("click",
()=>{
document.getElementById("content").innerText = "You Clicked Button";
});
</script>
</body>
</html>
Output
0 Comments
If you have any question please ask?