canceling a circle callback

canceling a circle callback

Hi Folks,

quick example:

  1. function endless(){
  2.     $("element").animate({left: '-=100'}, 1500);
  3.     $("element").slideToggle(500);
  4.     $("element").animate({left: '+=200'}, 1500, endless);
  5. }
this code will obviously repeat over and over, I'm wondering how to intercept that whole thing in a
jQuery'ish way? Is that possible without an own logic boolean check?

Kind Regards

*edited*
In the same context, a native js question. If one sets up a timer with setInterval, the returning identifier
for that timer is not changed when calling clearInterval(identifier).
Am I missing something or isn't there a method like isTimer(identifier) ?