I'm struggling with customizing the background color of the active page due to complex HTML structure. I'm using responsive twitter bootstrap (2) and facing challenges. To view all tabs at the top, you need to stretch the viewing window. Below is my code:
Check out the jsFiddle here: http://jsfiddle.net/2bhnQ/1/
The code snippet is as follows:
<div class="navbar navbar-inverse navbar-static-top">
<div class="navbar-inner">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse" href="#">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="index.php">HOME</a>
[The rest of the code...]
In an attempt to solve this issue, I referred to another solution from Stack Overflow but it didn't work as expected. Here's the script that I tried:
$(document).ready(function(){
alert(window.location.pathname);
$(".navbar navbar-inverse navbar-static-top .navbar-inner .container .nav-collapse .nav li a").each(function(){
if($(this).attr("href")==window.location.pathname)
$(this).addClass("active");
}) })
As a newbie programmer in my early days on the job, any guidance or support would be highly appreciated. Thank you.