javascript - How to get alert message on second click of a button -


i know how can alert message on second click of button, not on first click.

ex: <input type="button" value="message" onclick="showmessage()">

function showmessage(){     alert("it's second click message"); // alert message should shown on second click of button } 

use counter instead..

var count = 0; //global variable  function showmessage() {    if (count++ == 1) { //compare , increment counter      alert("it's second click message"); //this alert message shown on second click of button    }  }
<input type="button" value="message" onclick="showmessage()">


Comments

Popular posts from this blog

xml - Extract substrings with XSLT -

math - "ELO Rating" and how does "TSR Rating" work? -

How can do a tuple comparison in coffeescript similar to that in python? -