下面是JS代码:
var curr = null; //curr为当前tab的标题,在else中赋值
function addtab(href, tabtitle) {
if (curr) {
$('#contab').tabs('update', {
tab : curr,
options : {
title : tabtitle,
href : href,
selected : true
}
});
$('#contab').tabs('select', tabtitle);
} else {
$('#contab').tabs('add', {
title : tabtitle,
href : href,
closable : false
});
curr = $('#contab').tabs('getTab', tabtitle);
}
}
html中主要代码:
<div data-options="region:'center'" class="easyui-tabs" id="contab">
</div>
调用的时候传一个href和标题名称就可以了:
addtab('<%=request.getContextPath() %>/admin/userlist.jsp','员工管理')