phase shifting with javaScript? - Javascript DOM

Javascript examples for DOM:Document addEventListener

Description

phase shifting with javaScript?

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() {//  ww w  .  j  a  va  2  s . c  o m
    
var clicker = document.getElementById("click");
function phaseSwitch(el, msgs) {
    var flag = false;
    el.addEventListener('click', function() {
        console.log(msgs[+flag]);
        flag = !flag;
    });
}
phaseSwitch(clicker, ['hello', 'bye']);


    });

      </script> 
   </head> 
   <body> 
      <div id="click">
         click
      </div>  
   </body>
</html>

Related Tutorials