研究了两天ui.tabs,终于搞定,之前在网上下了一个老版本的api,好多方法在1.7都用不了
然后我就晕了.addTabs和removeTabs方法在1.7都没有了
而在网上看到别人写的一个符合我要求的代码就是老版本的,但我觉得不能放弃,一定要用新版本的UI
哎,突然发现这个博客的编辑功能很牛哦,要有代码看看就好
不费话了,放代码
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
Code
1![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
$(document).ready(function()
{
2![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
$('#tabs').tabs(
{add:addEventHandler}); //给tabs块绑定addEventHandler事件
3
$('#newtabs').click(addTab);
4![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
5
})
6![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
7
var tabCounter = 1;
8![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
function addTab()
{
9![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
if(tabCounter > 6)
{
10
alert('tabs can not more than 6!');
11
return;
12
}
13
$('<div id="new-tab-'+tabCounter+'">'+'New tab'+tabCounter+'</div>').appendTo('#tabs');
14
$('#tabs').tabs("add","#new-tab-"+tabCounter,'New tab'+tabCounter);
15
tabCounter++;
16
}
17![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
function addEventHandler(event,ui)
{
18
var li = $(ui.tab).parent();
19
$('<img src="close.gif"/>') //关闭按钮
20
.appendTo(li)
21![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
.hover(function()
{
22
var img = $(this);
23
img.attr('src','close_hover2.png');
24
},
25![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
function()
{
26
var img = $(this);
27
img.attr('src','close.png');
28
}
29
)
30![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
.click(function()
{ //关闭按钮,关闭事件绑定
31
var li = $(ui.tab).parent();
32
var index = $('#tabs li').index(li.get(0));
33
$("#tabs").tabs("remove",index);
34
tabCounter--;
35
});
36![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
$(ui.tab).dblclick(function()
{ //双击关闭事件绑定
37
var li = $(ui.tab).parent();
38
var index = $('#tabs li').index(li.get(0));
39
$("#tabs").tabs("remove",index);
40
tabCounter--;
41
});
42
}
43![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
在网上找了半天都没有1.7的API,有没有朋友可以告诉哪有下载