文檔金喜正規買球>>jQuery EasyUI使用教程>>jQuery EasyUI使用教程:動態添加標簽
jQuery EasyUI使用教程:動態添加標簽
Kendo UI for jQuery——創建現代Web應用程序的最完整UI庫!查看詳情>>>
通過使用jQuery EasyUI可以非常容易的動態添加標簽,你只需調用'add'方法即可。
在本教程中,我們將使用iframe動態添加標簽來顯示一個頁面。當點擊添加按鈕時,一個新的標簽將會被添加。如果標簽已經存在了,那么它將會被激活。

Step 1:創建標簽
<div style="margin-bottom:10px"> <a href="#" class="easyui-linkbutton" onclick="addTab('google','//www.google.com')">google</a> <a href="#" class="easyui-linkbutton" onclick="addTab('jquery','//jquery.com/')">jquery</a> <a href="#" class="easyui-linkbutton" onclick="addTab('easyui','//jeasyui.com/')">easyui</a> </div> <div id="tt" class="easyui-tabs" style="width:400px;height:250px;"> <div title="Home"> </div> </div>
該html代碼非常簡單,我們創建了帶有一個被命名為'Home'標簽面板的標簽。請注意,我們不需要編寫任何JS代碼。
Step 2:實現'addTab'功能
function addTab(title, url){ if ($('#tt').tabs('exists', title)){ $('#tt').tabs('select', title); } else { var content = '<iframe scrolling="auto" frameborder="0" src="'+url+'" style="width:100%;height:100%;"></iframe>'; $('#tt').tabs('add',{ title:title, content:content, closable:true }); } }
我們使用 'exists'方法來確定標簽是否存在,如果存在的話那么激活該標簽,如果不存在則調用'add'方法來添加新的標簽面板。
下載該EasyUI示例:
購買最新正版授權!""