开发者

JQuery Tabs & cookie plugins - 2 tabs highlighted

I'm using jquery with tabs plugin and the cookie plugin to remember the previously selected tab. However, when the page is opened again it successfully remembers the last tab selected but then when a new tab is chose开发者_如何学Gon both the new and the old one are highlighted. When another is selected then it just highlights that one.

$("#tabs").tabs({ cookie: { name: 'selectedTab', expires: 300 }});

Can anyone suggest a solution please? Thanks


http://jqueryui.com/demos/tabs/#cookie

Have you gone through this ?


As I commented, I would need to see more of you code to be sure, but my initial guess would be that you're probably highlighting the selected tabs using a CSS class. You have to make sure that you are also REMOVING that class from anywhere that it's already applied before applying it.

Similar to this:

$('.tab').click(function() {
    // First remove your highlight class from any tabs already highlighted
    $('.selectedTabHighlightClass').removeClass('selectedTabHighlightClass');

    // Then add the class to the newly selected tab
    $(this).addClass('selectedTabHighlightClass');  
});


it turns out that I needed the latest version of jquery installed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜