// put at the end of the page and it require jquery.min.js

$(function() {
     var pgurl = window.location.href.substr(window.location.href
.lastIndexOf("/")+1);
     $("#nav ul li a").each(function(){   // it will add active class to <a> you can remove a tag than it will for li like $("#nav ul li"). 
          if($(this).attr("href") == pgurl || $(this).attr("href") == '' )
          $(this).addClass("active");
     })
});

// it only work if href="home.php" and url="www.domain.com/home.php"

Recent Comments

0 Comments

Sign In To Leave a Comment

Type your Comment below and click to send comment

error: function(jqXHR, textStatus, errorThrown) { alert(errorThrown); }