need help with jquery selectors

Posted by photographer on Stack Overflow See other posts from Stack Overflow or by photographer
Published on 2010-04-01T00:14:57Z Indexed on 2010/04/01 20:03 UTC
Read the original article Hit count: 778

I've got code like that:

<ul class="gallery_demo_unstyled">
    <li class="active"><img src='001.jpg' /></li> 
    <li><img src='002.jpg' /></li> 
    <li><img src='003.jpg' /></li> 
    <li><img src='004.jpg' /></li> 
    <li><img src='005.jpg' /></li> 
    <li><img src='006.jpg' /></li> 
</ul> 

<div class="Paginator"> 
    <a href="../2/" class="Prev">&lt;&lt;</a> 
    <a href="../1/">1</a> 
    <a href="../2/">2</a> 
    <span class="this-page">3</span> 
    <a href="../4/">4</a> 
    <a href="../5/">5</a> 
    <a href="../4/" class="Next">&gt;&gt;</a> 
</div> 

<div class="Albums"><div class="AlbumsMenu">
<p><b>ALBUMS</b></p>
    <p><a href="../../blackandwhite/1/" >blackandwhite</a></p>
    <p><a href="../../color/1/" class='this-page'>>>color</a></p>
    <p><a href="../../film/1/" >film</a></p>
    <p><a href="../../digital/1/" >digital</a></p>
    <p><a href="../../portraits/1/" >portraits</a></p>
</div></div>  

...and some JavaScript/jQuery allowing to cycle through the images (the very top li elements) going back to the first image after the last one:

$$.nextSelector = function(selector) {
return $(selector).is(':last-child') ?
       $(selector).siblings(':first-child') :
       $(selector).next();

};

Current page is always 'this-page' class (span or p in my case, but I could change that if necessary).

The question: what should I change in my code to make it go after the last image to the next page instead of cycling through the page over and over again, and after the last page to the next album? And to the first image on the first page of the first album after the last-last-last (or just stop there — don't really care)?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery