Javascript examples for DOM:Element addEventListener
Element addEventListener() Method - Change the background color of a <button> element:
<!DOCTYPE html> <html> <body> <button id="myBtn">Test</button> <script> document.getElementById("myBtn").addEventListener("click", function(){ this.style.backgroundColor = "red"; });// w ww .j a v a2 s . c o m </script> </body> </html>