Simple onClick Every Other Click Javascript HTML -


onclick="handleaction(\'playnow\');handleaction(\'stop\');" 

performs 2 functions simultaneously. no since action \playnow\ , \stop\ after.

i need onclick perform function every other click.

click 1: \playnow\

click 2: \stop\

click 3: \playnow\

etc.

is there simple way achieve this?

define var holds current state:

var state = false;  function handleaction() {     if (state == false) {         // stuff 'playnow' action          state = true;         return;     }      if (state == true) {         // stuff 'stop' action          state = false;         return;     } } 

Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

c# - Exception when attempting to modify Dictionary -