jquery - Fixed navigation after scroll and CSS classes toggle -


I have created a simple web page layout, you can find it here:

After scrolling down, I managed to create fixed navigation The one I am struggling to achieve is to assign each list item to class = "active" as the user moves from section to section.

When the navigation is fixed on the top when the viewport wants me to add class = "active" to the first list item

  ; Li & gt; & Lt; A href = "#include" category = "active" & gt; Some & lt; / A & gt; & Lt; / li & gt;   

And then as soon as I move the page down, class = "active" is removed and then it is added to the next list item.

I have found some plugins that actually do this but the truth is that I have not integrated them into my project. Also, due to the fact that I am very new to jQuery, I do not understand the code.

I also found that it was difficult to consolidate once again ..

, what is your advice?

Thank you in advance

I included your update to a new block of JavaScript The example that you give handles highlighting menu options based on basal.

The block I added is:

$ ("-. (I) {if ($ (this) .position (). Top & lt; = Windscroll - hdr + 20) {mn.find ('a.active'). RemoveClass ('active'); Mn.find ('a'). Eq (i) .addClass ('active');}}) ;

It ends through each section, in which you have menu options and checks the scroll of the window. After reducing the height of the header and adding some padding back, That number has been compared to the position of the element on the page. If the position is higher than the position, mark the menu element as active.

Keep in mind that since this square is too small, so the last few sections can not highlight because you do not scroll it down Away.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -