Saturday, February 20, 2010

[jQuery] Re: Scrolling Problem

Thanks Nathan, it works as expected !
Great help !

On 20 fév, 21:34, Nathan Klatt <n8kl...@gmail.com> wrote:
> 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

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate