"Navbar active with jquery"
Bootstrap 3.3.0 Snippet by imsachin

<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="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <!------ Include the above in your HEAD tag ----------> <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="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <!------ Include the above in your HEAD tag ----------> <!DOCTYPE html> <html lang="en"> <head> <title>HTML</title> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="https://fonts.googleapis.com/css?family=Roboto:400,500,700" rel="stylesheet"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <!--[if IE]> <link href="~/Content/NewHomePage/all-ie-only.css" rel="stylesheet" /> <![endif]--> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> <link rel="stylesheet" href="style.css"> </head> <body> <div id="topheader"> <nav class="navbar navbar-default"> <div class="container"> <div class="navbar-header"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="#">Brand</a> </div> <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> <ul class="nav navbar-nav pull-right"> <li class="active"><a href="#home">home<span class="sr-only">(current)</span></a></li> <li><a href="#page1">page 1</a></li> <li><a href="#page2">page 2</a></li> <li><a href="#page3">page 3</a></li> </ul> </div> </div> </nav> </div> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> <script src="custom.js"></script> <script> $( '#topheader .navbar-nav a' ).on( 'click', function () { $( '#topheader .navbar-nav' ).find( 'li.active' ).removeClass( 'active' ); $( this ).parent( 'li' ).addClass( 'active' ); }); </script> </body> </html>
#topheader .navbar-nav li > a {text-transform: capitalize;color: red;transition: background-color .2s, color .2s;}/*unvisited link(normal link)*/ #topheader .navbar-nav li > a:hover {background-color: #fa7603;color: #fff;position:relative;}/*hover effect*/ #topheader .navbar-nav li.active > a {background-color: #000;color: #fff;}/*active code*/ /* #topheader .navbar-nav li > a:visited {background-color: #0d95cc;color: #000;} *//*vistied effect*/ #topheader .navbar-default .navbar-nav li a:active:after {z-index:999;content: ' ';position: absolute;top: 95%;left: 50%;width: 30px;border: 1px solid #fa7603;border-radius: 4px;box-shadow: inset 0 1px 1px rgba(0,0,0,.05);transform: translateX(-50%);} */

Related: See More


Questions / Comments: