开发者

jquery ui tabs, do some css when specific tab is active, selected

开发者 https://www.devze.com 2023-04-02 18:07 出处:网络
I would like to change some styling (for example body background color) when specific tab is selected (clicked) in jquery ui tabs.

I would like to change some styling (for example body background color) when specific tab is selected (clicked) in jquery ui tabs.

Sth like:

if (tab nr 2 is s开发者_运维问答elected) { $(body).css('background', 'red') }
if (tab nr 3 is selected) { $(body).css('background', 'blue') }

How can I check which tab is selected?


$('.ui-tabs-nav').bind('tabsselect', function(event, ui) {
     var index=ui.index;
     if(index===2){ 
        $(body).css('background', 'red')
     }
     else if(index===3){ 
        $(body).css('background', 'blue')
     }
 });

Tab select documentation

Tabs Events documenation


Looking at the documentation, you can use the event "enable" to keep track of this.

You could also do as such:

var $tabs = $('#example').tabs();
var selected = $tabs.tabs('option', 'selected');

(always from the documentation)

Generally speaking, read the documentation, you'll find your answer there.

0

精彩评论

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