是否有可用于 jQuery UI 的选项卡小部件的事件监听器?
我想根据当前处于事件状态的选项卡索引更改网页上的背景颜色。所以像这样(伪代码):
$('.tabs').addEventListener(index, changeBackgroundImage);
function changeBackgroundImage(index) {
switch (index) {
case 1:
$('body').css('background-image', '/images/backgrounds/1.jpg');
break;
case 2:
$('body').css('background-image', '/images/backgrounds/2.jpg');
break;
case 3:
$('body').css('background-image', '/images/backgrounds/3.jpg');
break;
default:
$('body').css('background-image', '/images/backgrounds/default.jpg');
break;
}
};
最佳答案
看来旧版本的 jquery ui 不再支持选择事件了。
此代码将适用于新版本:
$('.selector').tabs({
activate: function(event ,ui){
//console.log(event);
console.log(ui.newTab.index());
}
});
关于javascript - jQuery 的 UI 选项卡的事件监听器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5551211/