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

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -