GithubHelp home page GithubHelp logo

activenavigation's Introduction

ActiveNavigation

jQuery plugin adds an active navigation class based on the current URL.

If you are using navigation menus on your website you probably need to highlight the current page so the visitors or users on the website know on which page or part of the site they are on.

This can be done by adding a CSS class to the menu item to highlight it differently to the other menu items.

If you have navigation like this:

<menu id="nav"> 
  <ul>
    <li><a href="/">Home</a></li>
    <li><a href="/about/">About</a></li>
    <li><a href="/clients/">Clients</a></li>
    <li><a href="/contact/">Contact Us</a></li>
  </ul>
</menu>

And you want to highlight current menu item, for example, you are at the URL http://website.com/clients/mobile/, so you need the Clients link to get a class of "active" to indicate it's an active navigation item.

You can do it easily with call

$(document).activeNavigation("#nav")

The script will check the current page URL and compare it with the URLs in the menu and it will add a class to the menu item that macthes in the best way.

In the example above, it will add an active class to the Clients link.

If the current url is http://website.com/clients/mobile/and/something/more it will still highlight the Clients link because it is the best match.

You can check it live at https://github.com/viewflow/karenina

activenavigation's People

Contributors

vitaa avatar federicot avatar

Stargazers

Gagan B Mishra avatar hai avatar  avatar Muhammed Bilal avatar Iakov Lilo avatar Grigory Solomin avatar Angus H. avatar Stephy avatar  avatar Adrien Glitchbone avatar Josh Winn avatar Munkh-Altai avatar Gareth Johns avatar Jason Melgoza avatar Jonath Lee Eng Sing avatar Daria Knyazeva avatar  avatar Mikhail Podgurskiy avatar

Watchers

 avatar Jonath Lee Eng Sing avatar James Cloos avatar

activenavigation's Issues

it does not work for me

Hi,
I tried your code, created another file called about.html, but when I clicked in the link about it said file not found.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.