I\'ve been trying to implement snook.ca\'s Simplest jQuery Slideshow, but when applied to child elements inside a
instead of a straightforward stack
Just break your chaining after selecting the next li
. If there is no next li
, the length
of the result set will be 0
. When that happens, loop back to the beginning. Then, just finish your setup. Here is a revision on your JSBin code that shows it working:
$('header nav li').not('.current').children('p').hide();
setInterval(function(){
var $next = $('header nav li.current').children('p').hide()
.parent('li').removeClass()
.next('li');
if(!$next.length) $next = $('header nav li:first');
$next.addClass('current')
.children('p').show();
},3000);