jquery - Run and stop buttons implementation -
i want call function interpret_st()
when click run
, stop interpret_st
current execution when click stop
. right way it?
var interpret_st; $('#run').click(function(e) { interpret_st = settimeout(interpret(), 1); }); $('#stop').click(function(e) { cleartimeout(interpret_st); });
update wanted when clicked stop, want go out function interpret
almost :
- you have bad parenthesis (unless
interpret
function factory, of course) - as second argument number of millisecondes, might prefer use 10000 rather 1
here's fixed code :
var interpret_st; $('#run').click(function(e) { interpret_st = settimeout(interpret, 10000); }); $('#stop').click(function(e) { cleartimeout(interpret_st); });
Comments
Post a Comment