How to make a "loop" in JQuery?

How to make a "loop" in JQuery?

I am quite new in JQuery and I wanna know... how can I make some functions repeat them after they have triggered?

Like, I want that this will repeat if triggered:

$('.class').animate({ 'opacity' : 1 }, 1000);
$('.class').animate({ 'opacity' : 0 }, 2000);

First post here^^.