"Jquery Bootstrap navbar active on page click"
Bootstrap 3.3.0 Snippet by faisalkhan123

<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <ul class="nav navbar-nav"> <li><a href="<?php echo base_url(); ?>testing/about">About</a></li> <li><a href="<?php echo base_url(); ?>testing/resources">Resources</a></li> <li><a href="<?php echo base_url(); ?>testing/blog">Blog</a></li> </ul>
$(function(){ var url = window.location; $('ul.navbar-nav a').filter(function() { return this.href == url; }).parent().parent().parent().addClass('active'); $('ul.navbar-nav a').filter(function() { return this.href == url; }).parent().addClass('active'); });

Related: See More


Questions / Comments: