Scrolling to previous div in jQuery

I am using scrollTo plugin for jQuery on a website. I made a vertical scrolling div wher which I can scroll to another div by clicking on the buttons. And now I need to make a back button to go back to the previous div.

what i want is the opposite

this.next()

      

I tried

this.prev()

      

but that won't work.

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

      

+1


a source to share


2 answers


Try:

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

      



In events, this one represents a DOM element, not a jQuery object.

+1


a source


this

- reference to the original element - you will need to wrap it in a jQuery object before you can use jQuery methods such as prev()

:$(this).prev()



+1


a source







All Articles