HTMLify
addEventListener.html
Views: 563 | Author: shubh
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | //eventListener <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>event listener</title> <style> body { background-color: aquamarine; } button{ background-color:aquamarine; border: 2px solid black; border-radius: 5px; cursor: pointer; } </style> </head> <body> <h1 id="heading"> hi javascript </h1> <button id="btn">Click</button> <script> let btn = document.getElementById("btn"); btn.addEventListener("click", () =>{ console.log("button was click"); heading.innerText="working"; }); </script> </body> </html> |