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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -