FadeIn / FadeOut - How do I loop?
I currently have the following code, that fades in and out of 5 list items and works exactly as I want, although I must confess I am a JQuery newby and the following code could probably been done a lot cleaner.
-
<script type="text/javascript">
var $j = jQuery.noConflict();
$j(document).ready(function() {
$j('#title1').fadeIn(5000);
$j('#title1').fadeOut(5000, function () {
$j('#title2').fadeIn(5000);
$j('#title2').fadeOut(5000, function () {
$j('#title3').fadeIn(5000);
$j('#title3').fadeOut(5000, function () {
$j('#title4').fadeIn(5000);
$j('#title4').fadeOut(5000, function () {
$j('#title5').fadeIn(5000);
$j('#title5').fadeOut(5000);
});
});
});
});
});
</script>
What I'd like to know is how to get this to loop through indefinitely. i.e. when it fadeouts title5, it then start back at the top on title1 again and so on.