test
test

Reputation: 2466

jQuery active class on page scroller

here is the code: http://jsfiddle.net/5UzfT/

How can I add active class when scrolling thru contents?

Upvotes: 0

Views: 256

Answers (2)

adeneo
adeneo

Reputation: 318182

I'm assuming it's the menu items that are suppose to be active, if so add this to your links:

<a href="#" onClick="Animate2id('#c1', this);return false">Content 1</a>

and do:

<script type="text/javascript">
  function Animate2id(id2Animate, elm){
    $(elm).addClass('active').siblings().removeClass('active');
    var animSpeed=1500; //animation speed
    var easeType="easeInOutExpo"; //easing type
    $("html, body").stop().animate({scrollTop: $(id2Animate).offset().top}, animSpeed, easeType);
  }
</script>

FIDDLE

This will only work when clicking the menu!

Upvotes: 1

Prasenjit Kumar Nag
Prasenjit Kumar Nag

Reputation: 13461

Have a look at this

http://imakewebthings.com/jquery-waypoints/

Check the above menu changes active focus as you scroll down.

Upvotes: 0

Related Questions