admin管理员组

文章数量:1323524

I'm using jQuery UI tabs(). It adds "ui-tabs-selected" to the selected LI, but each LI has an ID because it's different. Due to the multi ID/class bug in IE6, I need to apply a "selected" class to the anchor that is inside the "ui-tabs-selected" LI.

Can someone tell me how to do this?

I'm using jQuery UI tabs(). It adds "ui-tabs-selected" to the selected LI, but each LI has an ID because it's different. Due to the multi ID/class bug in IE6, I need to apply a "selected" class to the anchor that is inside the "ui-tabs-selected" LI.

Can someone tell me how to do this?

Share Improve this question asked Apr 23, 2011 at 4:23 CofeyCofey 11.4k16 gold badges54 silver badges75 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 7

you can do

$('li.ui-tabs-selected a').addClass('yourclass');

To manually add a class to any of the tabs you can do assuming your ul has the id #tabs

$('#tabs li a').eq(1).addClass('yourclass'); //this will add class to second tab

Updated Answer Use the select event to trigger addClass()

$('#wrap').tabs({
    select: function(event, ui) {
        $(this).find('li a').removeClass('myclass').eq(ui.index).addClass('myclass')
    }
});

Check working example at http://jsfiddle/6JryL/

$('.ui-tabs-selected a').addClass('selected');

本文标签: javascriptHow to add a quotselectedquot class to a selected tab anchor using jQuery UI TabsStack Overflow