On Sat, Feb 20, 2010 at 9:13 AM, macgyver47 <jrl...@wanadoo.fr> wrote: > div1 class="post" > div class="title" > .... > div10 id="post" > div class="title" > I am trying: clicking on div#title belonging to div1 scrolls to > div#title belonging to div2 and so on
$().ready(function() { $(".title").click(function() { var thisPost = $(this).parent(); var nextPost = thisPost.next(".post"); if ( ! nextPost.length ) nextPost = thisPost.parent().find(".post"); var positionOfNextTitle = nextPost.find(".title").position(); // or offset() window.scrollTo(positionOfNextTitle.left, positionOfNextTitle.top); }); }); http://jsbin.com/adoti/edit Nathan