1

I currently have a sharepoint site setup with subsite links located on the left-hand side, but the text for each link are the same color. I would like know how to make each link text a different color?

0

So basically you are going to have to access the list items in the menu and then set the colours from there. You will have to access the item by it's class as the ID is dynamically created so:

var nodeList= document.getElementsByClassName("ms-core-listMenu-root");
var listItems = nodeList[0];

You will then have to set the colour of each item in the list:

for(var i=0; i<listItems.length; i++){
  listItems[i].style.color="#00FF00";
}

You will just need to create an array of different colours and loop through that at the same time you are looping through the links.

Hope this helps.

  • I am basically a beginner with Sharepoint, and I am unsure exactly how I go about accessing the code to make the modifications that you listed above. The Master file does not show subsite information. I know where to make the changes when you inspect the element of the page but those changes can be saved. – Kyle Feb 2 '16 at 13:30
  • I am not sure how you are going to do by sub site. My solution merely hooks into the section where sub sites and lists are displayed. You would have to further add logic to ensure the section you are modifying is the list of sites. I am not sure where SharePoint builds the list. I assume there is some code in behind that does it as I don't believe it is done in one of the .js files. This means you have to wait for the page to render to modify the list. You can do this by attaching a .js file to your master page or adding the code directly to the master page (not recommended). – David Drever Feb 4 '16 at 16:30
0

You can override style for menu Items in masterpage or alternate style section (From master page change menu you can see it). You can find those Item class or html tag using browser developer tools easily.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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