基本jquery的控制tabs打开的数量的代码


复制代码 代码如下:

var tabcount = $('#tabs').tabs('tabs').length;修改addTab 方法为:function addTab(subtitle, url, icon) {
var tabcount = $('#tabs').tabs('tabs').length;
if (tabcount <= 5) {
if (!$('#tabs').tabs('exists', subtitle)) {
$('#tabs').tabs('add', {
title: subtitle,
content: createFrame(url),
closable: true,
icon: icon
});
} else {
$('#tabs').tabs('select', subtitle);
$('#mm-refresh').click();
}
} else {
alert('您打开的太多了,请关闭不用的窗口!');
return false;
}

这样允许打开的最大数量为5个(不包括欢迎页)。可根据需要自行修改复制代码 代码如下:
var tabcount = $('#tabs').tabs('tabs').length;修改addTab 方法为:function addTab(subtitle, url, icon) {
var tabcount = $('#tabs').tabs('tabs').length;
if (tabcount <= 5) {
if (!$('#tabs').tabs('exists', subtitle)) {
$('#tabs').tabs('add', {
title: subtitle,
content: createFrame(url),
closable: true,
icon: icon
});
} else {
$('#tabs').tabs('select', subtitle);
$('#mm-refresh').click();
}
} else {
alert('您打开的太多了,请关闭不用的窗口!');
return false;
}

这样允许打开的最大数量为5个(不包括欢迎页)。可根据需要自行修改
« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3