views:

1106

answers:

2

I'm using the scrollTo plugin for jQuery on a website. I made a vertical scrolling div wher I can scroll to different div by clicking on buttons. And now I need to make a back button to return to the previous div.

what I want is the opposite of

this.next()

I tried

this.prev()

but it doesn't work.

$('#tabs').click
(
    function()
    {
        $('#wrapper').scrollTo(this.prev(), 'medium')
    }
);
+1  A: 

this is a raw element reference - you'll need to wrap it in a jQuery object before you can use jQuery methods like prev(): $(this).prev()

Shog9
+1  A: 

Try:

$('#tabs').click
(
    function()
    {
        $('#wrapper').scrollTo($(this).prev(), 'medium')
    }
);

In events this represents the DOM element, not the jQuery object.

jakemcgraw
yes, that's what I did after reading Shog9's answer and it works.but thanks anyway, and your answer is clearer than his.
Philippe Mongeau