Skip to content Skip to sidebar Skip to footer

Jquery Selected Tab Problem?

I'm fairly new to JQuery and for some reason I can't get the currently selected tab to highlight correctly it should be a different color when selected. Can some one help me fix th

Solution 1:

Try changing these lines:

$("#menu ul li").removeClass("selected-link");
$(this).addClass("selected-link");

To:

$("#menu ul li").find('a').removeClass("selected-link");
$(this).find('a').addClass("selected-link");

You want to add class to link not li.

Solution 2:

Edit

$(document).ready(function() {

    //When page loads...
    $(".form-content").hide(); //Hide all contentvar firstMenu = $("#menu ul li:first");
    firstMenu.show();
    firstMenu.find("a").addClass("selected-link"); //Activate first tab
    $(".form-content:first").show(); //Show first tab content//On Click Event
    $("#menu ul li").click(function() {

        $("#menu ul li a").removeClass("selected-link"); //Remove any "selected-link" class
        $(this).find("a").addClass("selected-link"); //Add "selected-link" class to selected tab
        $(".form-content").hide(); //Hide all tab contentvar activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the selected-link tab + content
        $(activeTab).fadeIn(); //Fade in the selected-link ID contentreturnfalse;
    });

});

"

Post a Comment for "Jquery Selected Tab Problem?"