javascript - Create an alert on div after third click count -


how can create alert after div being clicked third time? tried examples already, failed on making work.

here's code far (without count part):

$("div").one( "click", function() {  $(this).css({   background: "red",   cursor: "auto",  });  $(this).append( "0" );  $("span").append( "0" ); }); 

fiddle http://jsfiddle.net/7gosayyo/

need use javascript keep track of how many times has been clicked.

<button onclick="clicking()>click me</button>    var nclicks    = 0; var nmaxclicks = 3;  function clicking() {     // increment counter each time item clicked     nclick++;      // on 3rd click....     if (nclicks == nmaxclicks){        // enter code thing looking        alert("max clicks hit! " + nclicks);        } } 

Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -