HTML Editor
<!DOCTYPE html> <html lang="en-US"> <body> <p>Click on the button to alert.</p> <button>Click Me</button> <script> var x = document.getElementsByTagName("button")[0]; function myFunction(){ alert("You clicked the button"); } x.addEventListener("click", myFunction); </script> </body> </html>
OUTPUT
×

Save as Private