jquery - stop a function declared inside setInterval() using clearInterval() -


how stop function declared inside setinterval(), like

var start = function(){     setinterval(function(){//do something},3000) };  var stop = function() {     clearinterval(start); };  $('button.start').click(function(){     start(); });  $('button.stop').click(function(){     stop(); }); 

but still not able stop setinterval function here. need little on that. thanks

declare variable interval .

setinterval create id.

then assign setinterval id inertval variable .

if wanna stop setinterval pass inertval clearinterval

try

var interval; var start = function(){     interval=setinterval(function(){        //do     },3000) };  var stop = function() {     clearinterval(interval); }; 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -