Skip to content

Instantly share code, notes, and snippets.

@daverogers
Created April 12, 2013 22:41
Show Gist options
  • Save daverogers/5375778 to your computer and use it in GitHub Desktop.
Save daverogers/5375778 to your computer and use it in GitHub Desktop.
Assign "active" class to navbar item based on current page URL with jQuery
<!-- your average Bootstrap navbar component, in this case placed in an include called header.html -->
<div class="navbar">
<div class="navbar-inner">
<ul class="nav">
<li><a href="/">Home</a></li>
<li><a href="/about.php">About</a></li>
<li><a href="/contact.php">Contact</a></li>
</ul>
</div>
</div>
@ankitribadia
Copy link

Thanks for the help

@SabineAvalisto
Copy link

Thank you very much! it's works

@xpuig
Copy link

xpuig commented Apr 27, 2020

Thx! Simple and effective 👍

@seasonC
Copy link

seasonC commented May 18, 2020

Works like a charm. Thanks man.

Copy link

ghost commented May 20, 2020

I have been looking for something like this FOR DAYS!! thank you from a rookie!

@destinyd081
Copy link

Good job...please how do I make each page of this code active
`



    <?php

                $query = "select* from main_menus";
                $result = mysqli_query($con,$query);
    
                while($row = mysqli_fetch_assoc($result)) {
                    $main_menus_id = $row['menu_id'];
                    $menu_title = $row['menu_title'];
                    $menu_url = $row['menu_url'];
              ?>
            <li class="nav-item ">
              <a href="<?php echo $menu_url ?>"><?php echo $menu_title ?></a>
            </li>
            <?php 
          }
          ?>
          </ul>
        </div>`
    

@earlpearl17
Copy link

Thank you sir.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment