How to start and stop/pause setInterval? How to start and stop/pause setInterval? jquery jquery

How to start and stop/pause setInterval?


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  });});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><input type="number" id="input" /><input id="stop" type="button" value="stop" /><input id="start" type="button" value="start" />