Javascript examples for DOM:Document addEventListener
phase shifting with javaScript?
<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>