0
How can i bind an event in JavaScript?
someone please describe how can we bind event in JS with example. Thanks in advance:)
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);