I wrote some classes in one of my SharePoint sites, that when you click on one of the links in the current navigation, the background color of the item changes to #eb8c00 :


#sideNavBox .ms-core-listMenu-selected:link,#sideNavBox .ms-core-listMenu-selected:visited,#sideNavBox .ms-core-listMenu-selected{
background-color: #eb8c00 !important;
color: #fff;


unction OrderQL() {
     $( "#sideNavBox a.selected" ).each(function( ) {

     /*set dynamic css logic*/
     $("#sideNavBox ul.root>li.static").css("border-bottom","1px solid #d6d6d6");
      $("#sideNavBox ul.root>li.static").css("border-top","1px solid #fff");

     if($('#sideNavBox .menu-item.selected').length){
      //propagates the selected class, up the three.
      $('#sideNavBox .menu-item.selected').parents('li.static').addClass('selected');

It's worked fine in all of my sites, but now i have a site that all of the links in the current navigation leads to the same view, with different parameters.

Example of 2 link in the current navigation: /Mysite/myzone/TaxDepartment/DocLib/Forms/view5.aspx?Qatg=IAS /Mysite/myzone/TaxDepartment/DocLib/Forms/view5.aspx?Qatg=DD

Because of that, the code treat all of the links as one, and it change the color of the last link no matter on which one i clicked.

I really appreciate any kind of help.

1 Answer 1


This sounds more like an issue with SharePoint. Even if you remove the customisations you can see the last link is selected irrespective of which link you clicked.

Workaround is first fix the navigation element and then addClass

$("#sideNavBox .menu-item.selected").removeClass("selected");
var query = window.location.pathname.split('/').pop() + location.search
var link = $("a[href*='" + query + "']:first");
var table = $(link).parent().parent().parent().parent();
table.addClass ("selected");   

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.