0

I'm currently making a navigation with .active class as the user scrolls, but the first anchor doesn't have an .active class unless you will scroll. Anyway, it's quite hard to explain. Please check this fiddle: http://jsfiddle.net/7nrLU/5/ Feel free to suggest other better way, but not CSS3. Thank you!

4
  • You could put $('.navigation a.a1').addClass('active'); inside document ready, before $(window).bind(...? Commented Jun 26, 2012 at 6:49
  • Can't you just put the class in the markup? Commented Jun 26, 2012 at 6:49
  • @AlexBall, thanks you! It works. Musa, I think it's better if jquery will do that =) Commented Jun 26, 2012 at 6:55
  • @user1441816, I am happy that it works, I post as an answer :-) Commented Jun 26, 2012 at 7:14

3 Answers 3

2

Add my solution, in addition to other viable solutions ;-)

$(document).ready(function() {
     $('.navigation a.a1').addClass('active');
     ...
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. I'm looking forward on you answer lately. =)
0

Add a .scroll() to immediatly run the event, like this: http://jsfiddle.net/7nrLU/6/

Comments

0
$('.navigation a:first').addClass('active');

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.