0

How can i bind an event in JavaScript?

someone please describe how can we bind event in JS with example. Thanks in advance:)

20th Nov 2016, 4:23 PM
Zam
Zam - avatar
1 Antwort
+ 4
it is element.addEventListener(event, function) for example we want to do change its color on clicking a button var button=document.querySelector("button") function changecolor(){ button.style.background="black"; } button.addEventListener("click".changecolor);
20th Nov 2016, 4:30 PM
Sandeep Chatterjee