var next = $('.rotator ul li:first'); if (current.next().length){ if (!current.next().hasClass('show')) { next = current.next(); }; };