Why not use an anchor? A very simple example, $(document).ready(function() { $('.item').each(function(i) { $(this).before('<a name="anchor' + i + '"></a>'); });
$('#next').click(function() { // get current anchor var match = self.location.href.match(/#anchor(\d+)$/); if (match !== null) { var ca = match[1]; ca++; self.location.href = '#anchor' + ca; } else { self.location.href = '#anchor0'; } }); $('#prev').click(function() { // get current anchor var match = self.location.href.match(/#anchor(\d+)$/); if (match !== null) { var ca = match[1]; ca--; if (ca >= 0) { self.location.href = '#anchor' + ca; } } }); }); You will need some way to make sure the Next and Previous buttons stay visible, but that could be a general idea. On 9/15/07, Fabien Schwob <[EMAIL PROTECTED]> wrote: > > > Hello, > > I would like to develop a "next item" in jQuery but I can't find how > to develop it. I have found how to get the offset of an element (with > .offset()), but I can't find how to go to this offset. > > For example the html is : > > <div id="items"> > <div class="item"> > </div> > <div class="item"> > </div> > </div> > > And I will have a "next" and "previous" button to navigate through the > .item. > > Thanks in advance. > > -- > Fabien SCHWOB > -- Ted