I\'m trying to pause and then play a setInterval loop.
After I have stopped the loop, the \"start\" button in my attempt doesn\'t seem to work :
See Working Demo on jsFiddle: http://jsfiddle.net/qHL8Z/3/
$(function() {
var timer = null,
interval = 1000,
value = 0;
$("#start").click(function() {
if (timer !== null) return;
timer = setInterval(function() {
$("#input").val(++value);
}, interval);
});
$("#stop").click(function() {
clearInterval(timer);
timer = null
});
});