0

I am using mCustomScrollbar script for custom scroll bar effect now I want to scroll page on specific class element. Class position is not fixed, It can be top or bottom.

In my example I have one anchor link and I want to page scroll to active class. Page will scroll only when user click to anchor.

Here is my JS Code:

$( "#scroll" ).click(function() {
    //scroll page to active class
});

$("#content_1").mCustomScrollbar({
    scrollButtons: {
        enable: true
    }
});

Here is my JSFiddle: http://goo.gl/6dpT7l

Note: Scroll position is not fixed. It can be anywhere UP/Down.

Any Idea? How to do this?

Thanks.

Mr.Happy
  • 2,559
  • 8
  • 32
  • 67

1 Answers1

0

In your fiddle, it seems to be as simple as scrolling to the paragraph in question's position().top attribute. Replace your alert with this:

$("#content_1").mCustomScrollbar('scrollTo', $('.active').position().top);
Curtis Autery
  • 76
  • 1
  • 4