Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to make the navbar tab active on click?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 8.71k
    Comment on it

    To make the clicked tab active in the navigation bar, the <li> corresponding to the clicked href in index.html introduces the css of 'active' class and removes the 'active' class from the previous <li> on click.

    Example:

    index.html

    <ul class="nav navbar-nav navbar-right menul">
        <li class="active"><a href="#">HOME</a></li>
        <li><a href="about">ABOUT</a></li>
        <li><a href="services">SERVICES</a></li>
        <li><a href="register">REGISTER</a></li>
         <li><a href="contact">CONTACT</a></li>
    </ul>
    

    abc.js

    $(document).ready(function(){
                $('li').click(function() {
                $("li.active").removeClass("active");
                $(this).addClass('active');
    });
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: