Apply "use strict" in event handler - Javascript DOM

Javascript examples for DOM:Event

Description

Apply "use strict" in event handler

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){// www  . jav a 2 s .  c o  m
document.getElementById("p1").addEventListener("click", function(){
  "use strict";
  console.log("P1 BUTTON CLICKED!!!");
});
    }

      </script> 
   </head> 
   <body> 
      <button id="p1">Player 1</button> 
      <button id="p2">Player 2</button> 
      <button id="reset">Reset</button>  
   </body>
</html>

Related Tutorials