-1

After I've called a jquery method that is part of a plugin, I want to terminate what it is doing. The plugin has an internal function that continously gets called with setTimeout. When my html content no longer needs this plugin, I want to stop the plugin otherwise its internal function goes on indefinitely. I thought that maybe I can either remove the plugin from the element that it is attached to or call clearInterval on the internal timer but I'm not sure how to access that from the object the plugin is attached to.

Johann
  • 27,536
  • 39
  • 165
  • 279

1 Answers1

0

You can use the clearTimeout() method to clear your setTimeout().

More info here and here.

Community
  • 1
  • 1
Wellington Zanelli
  • 1,894
  • 3
  • 18
  • 43
  • I think the OP knows that (though the question mentions `clearInterval()` rather than `clearTimeout()`). Isn't the main point that he or she doesn't know how to access the internals of the plugin to get the timer id to pass to `clearTimeout()`? – nnnnnn Aug 21 '13 at 11:32
  • He must use the `clearTimeout()` instead of `clearInterval()`. That's the only answer that I can do without more info about the plugin. – Wellington Zanelli Aug 21 '13 at 11:38