SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to do the same as done here with some Javascript?

AspMenu does not render css-class for 'selected' element

I want to use this CSS for the selected item in the menu

.s4-tn > .menu-horizontal ul li a.selected {
color: #ffffff!important;
background-color:#4682B4; /*Fallback*/
background: -webkit-gradient(linear, left top, left bottom, from(#4682B4), to(#4682B4));
background: -moz-linear-gradient(top, #4682B4, #4682B4);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#4682B4, endColorstr=#4682B4);
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#4682B4, endColorstr=#4682B4)";
share|improve this question

You could use jquery to select the tag that you want by the class/id/type of that and change the CSS by the css jquery property.

For example:

$("div").click(function () {
  var html = ["The clicked div has the following styles:"];
  var styleProps = $(this).css( ["width", "height", "color", "background-color"] );
  $.each( styleProps, function( prop, value ) {
    html.push( prop + ": " + value );
  $( "#result" ).html( html.join( "<br>" ) );

More information:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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