Javascript listen for 2nd click -


i have script using.i when user clicks once changes var 0 when user clicks again changes var 3 , repeats. click again 0 3 @ moment part want detect 2nd click 'mousemove'.can please below code.

window.addeventlistener('load', function () {      function go() {          = < height ? + step : 1;          m.style.margintop = -i + 'px';      }      var = 0,          step = 3,          space = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';      var m = document.getelementbyid('marquee');      var t = m.innerhtml;      m.innerhtml = t + space;      m.style.position = 'absolute';      var height = (m.clientheight + 1);      m.style.position = '';      m.innerhtml = t + space + t + space + t + space + t + space + t + space + t + space + t + space;  	// first click  	m.addeventlistener('click', function () {          step = 0;      }, true);      // second click      m.addeventlistener('mousemove', function () {          step = 3;      }, true);        var x = setinterval(go, 50);  }, true);

one approach set click counter. if click counter set step zero, if odd set 3.

  var clickcounter = 0;    m.addeventlistener('click', function () {         step = (clickcounter++ % 2 === 0 ? 3 : 0);   }, true); 

demo: http://jsfiddle.net/byrkfvvk/

another approach have internal property use boolean toggle.

  document.getelementbyid('button').addeventlistener('click', function () {       this.active = !this.active;       step = (this.active ? 3 : 0);   }, true); 

demo: http://jsfiddle.net/h8hu4sm0/1/


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -