javascript - Issue on Resetting Custom jQuery Spinner -


i have simple custom jquery spinner @ this demo working fine me having issue on resetting value initial. can see demo , following code able set text of #targeteg .html(targets[0]); if start + or - counter again continues before setting value counting!

var targets = ["target km", "1,000 km", "3,000 km", "5,000 km", "7,000 km"]; var = 0; $("#plus").on("click", function () {  if (i < 4) {        $("#targeteg").html(targets[++i]);  } }); $("#minus").on("click", function () {  if (i > 0) {         $("#targeteg").html(targets[--i]);   } }); $("#resetform").on("click", function () {  mapreset();  function mapreset() {   $("#targeteg").html(targets[0]);  } }); 

can please let me know how fix after resetting every thing starts beginning reloading page time. thanks

just set i=0 in reset function

function mapreset() {     = 0;     $("#targeteg").html(targets[0]); } 

working demo


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -