Reputation: 8079
I am trying to write a function that applies an action through all <strong>
elements, and when finishes with one, applies it to the next one.
Also, at the end, it must start again with the first <strong>
.
I am sure I remember reading about a jquery function for doing this, but I cannot remember it.
Upvotes: 1
Views: 98
Reputation: 322582
For it to infinitely loop, you'll need to use something like setInterval()
so it doesn't block other javascript from executing.
I assume that's what you mean when you say "Also, at the end, it must start again with the first again."
Here's an example: http://jsfiddle.net/34sFN/
Another example, somewhat based on your comment: http://jsfiddle.net/34sFN/1/
var $ems = $('em');
// Loops through all your elements every 100 milliseconds.
// Change the duration to suit.
setInterval(function() {
$ems.each(function() {
// Do something to the current EM using $(this)
});
},100);
Upvotes: 2
Reputation: 413966
$('selector').each(function() {
$(this).doSomething();
});
?? Upon each call to that function embedded there, "this" will refer to one of the elements selected by the given selector (like "input:checked" or whatever).
Upvotes: 4