Blair Mitchelmore schrieb:
> And I just realized I should make it possible to stop the repeating
> function later on.
>
> Code:
> jQuery.fn.every = function(interval,fn) {
> return this.each(function() {
> var self = this;
> this.$every = window.setInterval(function() { fn.call(self)
> },interval);
> });
> };
>
> Example:
> // Display the current time updated every 500 ms
> $("p.display").every(500,function() {
> $(this).html(new Date());
> });
>
> //... some point later in the code execution
> $("p.display").each(function() {
> window.clearInterval(this.$every);
> this.$every = null;
> });
>
You could package that in a second plugin method. Just need to find a
nice name...
In addition, it may be helpful to be able to pass arguments to the
function. There may be cases where you can't rely on a closure to "pass"
arguments.
-- Jörn
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/