I have an object filled with various elements that I wish to iterate through using each() and then perform an action on the element whose turn it is. So:
var arts = $("#press-sqs > article");
shuffle(arts);
$(arts).each(function(){
setInterval(function() {
// in here perform an action on the current element in 'arts'
}, 2000);
});
( shuffle() is a basic shuffle function )
What I can’t figure out is how to access the current element as a selector and perform an action on it. $(this) is $(window).
Finally I would then need the function to start the iteration again once it reaches the end of art and keep on looping ad infinitum.
If you’re using
setInterval, you’d get identical results swapping the order:I don’t think you want what you think you do here. I reckon you want: