How to alert with button.


<!DOCTYPE html>


<html>


  <head>


    <title>background change</title>


  </head>


  <body style=”background:black;text-align:center;”>


  <h1 style=”background:blue;”>Click button to alert</h1>


    <button id=”tio” style=”background:blue;width:20em;height:5em;”>click</button>


    <script>
      document.getElementById(“tio”).onclick= function(){
      alert(‘hello’)
      }
    </script>


  </body>


</html>


Leave a Comment