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

I'm trying to remove the classstatic selected menu-item using

 $("#slink").removeClass("static selected menu-item");

Thanks guys.I'm sure the Jquery script is running as i have other stuff there. More wider snippet here:

<div id="zz18_TopNavigationMenuV4" class="s4-tn">
    <div class="menu horizontal menu-horizontal">
        <ul class="root static">
            <li class="static selected">
            <a id="slink" class="static selected menu-item" href="/sites/mySite" accesskey="1">
            <span class="additional-background"><span class="menu-item-text">Home</span><span class="ms-hidden">Currently 
            <ul class="dd_menu root static">
                <li class="static selected">
                <a id="slink" href="/sites/mySite/Tool/default.aspx" class="static selected menu-item">
                <span class="additional-background">
                <span class="menu-item-text">Tool</span></span></a></li>

But no luck so far.Any ideas?

share|improve this question
Your code looks good. I suspect your problem may not be that line of jQuery. I suspect either the HTML is being generated on the fly (by Javascript etc ...) or that jQuery line isn't being called. Can you post a wider example of your code. – Chris Felstead Nov 28 '11 at 8:19
Ensure the jQuery library is being run, can you run the IE dev toolbar and debug your code? That may lead to an issue as well – David Lozzi Nov 28 '11 at 12:30
Thanks guys.I'm sure the Jquery script is running as i have other stuff there. More wider snippet here: – naijacoder Nov 29 '11 at 0:24
I would try the removeClass with one class at a time, I'm not 100% sure that the removeClass method supports multiple classes like that. – James Love Nov 29 '11 at 9:08
@JamesLove This is possible – Daniel Ziga Nov 29 '11 at 9:17

When using jQuery or general javascript for that matter, in a ASP.NET masterpage, it's very important that you know where to put it to make sure it takes effect.

If the javascript is placed in the header it is not always certain that the script will be read in time for the element to get affected by it. This can be solved by moving the <script> tag containing the javascript down beneath the HTML which is should have an effect on, like so

<div id="Div1"><p class='class1 class2'>Pretend this is in your masterpage<p></div>
<script type='text/javascript'>
$(document).ready(function () { 
    $('#Div1 p').removeClass('class1 class2');

Hope this helps you.

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.