Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm using a idTabs to build a tab menu and i'm almost there. But how can i add a class when a tab is selected to the li element class=current(which is the parent) if the anchor is class =SELECTED. And when the class in the anchor is SELECTED and element li class is CURRENT i want to remove the current from all other li element

Thanks in advance

$(document).ready(function(){ $("#outer ul").idTabs(); });

<div id="outer">
<ul class="tabby">
    <li><a href="#Home" class="selected">Home</a></li>
    <li><a href="#NewPages">NewPages</a></li>
</ul>


<div id="NewPages" style="display: none;">
    <ul id="subby_NewPages">
        <li>
        <a href="" class="selected">
        <b>Plans</b></a></li>
        <li>
        <a href="">
        <b>Process</b></a></li>
        <li>
        <a href="">
        <b>Stores </b></a></li>
    </ul>
</div>

<div id="Home" style="display: block;">
    <ul id="subby_Home">
        <li>
        <a href="" class="selected">
        <b>Retail</b></a></li>
    </ul>
</div>
share|improve this question
add comment

1 Answer

So the first bit is to find the li you're looking for which in jQuery is done using Selectors. In your case you want a class selector for "selected" and then get the parent object (an li). The selection of a parent is described in this forum post.

Your code will look something like the following

$(".selected").parent().addClass("CURRENT")
share|improve this answer
    
Thanks Neil but the link to the forum doesn't exist –  Patrick Jan 13 '11 at 23:33
    
forum.jquery.com/topic/… –  Neil Richards Jan 14 '11 at 6:58
add comment

Your Answer

 
discard

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.