Chrome Extension

document.addEventListener javascript

document.addEventListener("click", function(){
    console.log("I am clicked")
});

//OR ADD EVENT ON A PARTICULAR EVENT
var button = document.getElementById("button");
button.addEventListener("click", function() {
    console.log("I am clicked on a button");
});
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place. Check how cool is the tool

If you want to add an event on an HTML element you can add that by using "addEventListener" used in javascript. List of events that can be triggered using addEventListener is as below.

'click' - To add click event on an element

'blur' - Triggers when focus out from an element

'keyup' - Trigger after releasing pressed key on applied element

'keypress' - Triggers while pressing key on applied element

Was this helpful?
0 Comments