Cycle through news items and display w/ animation
Made in response to:
http://stackoverflow.com/questions/7517987/toggle-between-divs-inside-another-div-using-jquery
HTML
<div id="news">
<span>Latest News!</span>
<div>
//News 1
</div>
<div>
//News 2
</div>
<div>
//News 3
</div>
</div>
JavaScript
function switchNewsItem(){
$('#news div:visible').fadeOut(function(){
$(this).next().length ? $(this).next().fadeIn() : $('#news div').eq(0).fadeIn();
});
};
$('#news div').hide().eq(0).show(); // show only the first news item
setInterval(switchNewsItem, 2000);