廢話不多說,直接上代碼吧!
讓客戶滿意是我們工作的目標(biāo),不斷超越客戶的期望值來自于我們對這個行業(yè)的熱愛。我們立志把好的技術(shù)通過有效、簡單的方式提供給客戶,將通過不懈努力成為客戶在信息化領(lǐng)域值得信任、有價值的長期合作伙伴,公司提供的服務(wù)項目有:空間域名、網(wǎng)絡(luò)空間、營銷軟件、網(wǎng)站建設(shè)、曲周網(wǎng)站維護(hù)、網(wǎng)站推廣。
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>layui</title> <meta name="renderer" content="webkit"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <link href="layui/css/layui.css" rel="external nofollow" rel="stylesheet" /> <script src="layui/layui.js"></script> <!-- 注意:如果你直接復(fù)制所有代碼到本地,上述css路徑需要改成你本地的 --> </head> <body> <div class="layui-layout layui-layout-admin"> <div class="layui-header"> <div class="layui-logo">layui 后臺布局</div> <!-- 頭部區(qū)域(可配合layui已有的水平導(dǎo)航) --> <ul class="layui-nav layui-layout-left"> <li class="layui-nav-item"><a href="">控制臺</a></li> <li class="layui-nav-item"><a href="">商品管理</a></li> <li class="layui-nav-item"><a href="">用戶</a></li> <li class="layui-nav-item"> <a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >其它系統(tǒng)</a> <dl class="layui-nav-child"> <dd><a href="">郵件管理</a></dd> <dd><a href="">消息管理</a></dd> <dd><a href="">授權(quán)管理</a></dd> </dl> </li> </ul> <ul class="layui-nav layui-layout-right"> <li class="layui-nav-item"> <a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" > <img src="http://t.cn/RCzsdCq" class="layui-nav-img"> 賢心 </a> <dl class="layui-nav-child"> <dd><a href="">基本資料</a></dd> <dd><a href="">安全設(shè)置</a></dd> </dl> </li> <li class="layui-nav-item"><a href="">退了</a></li> </ul> </div> <div class="layui-side layui-bg-black"> <div class="layui-side-scroll"> <!-- 左側(cè)導(dǎo)航區(qū)域(可配合layui已有的垂直導(dǎo)航) --> <ul class="layui-nav layui-nav-tree" lay-filter="test"> <li class="layui-nav-item layui-nav-itemed"> <a class="" href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >所有商品</a> <dl class="layui-nav-child"> <dd><a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >列表一</a></dd> <dd><a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >列表二</a></dd> <dd><a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >列表三</a></dd> <dd><a href="">超鏈接</a></dd> </dl> </li> <li class="layui-nav-item"> <a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >解決方案</a> <dl class="layui-nav-child"> <dd><a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >列表一</a></dd> <dd><a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >列表二</a></dd> <dd><a href="">超鏈接</a></dd> </dl> </li> <li class="layui-nav-item"><a href="">云市場</a></li> <li class="layui-nav-item"><a href="">發(fā)布商品</a></li> </ul> </div> </div> <div class="layui-body"> <div > <div class="layui-tab" lay-filter="demo" > <ul class="layui-tab-title" > <li class="layui-this" lay-id="11" id="11">網(wǎng)站設(shè)置 </li> <li lay-id="22">用戶管理 <i class="layui-icon layui-unselect layui-tab-close">ဆ</i></li> <li lay-id="33">權(quán)限分配</li> <li lay-id="44">商品管理</li> <li lay-id="55">訂單管理</li> </ul> <div class="layui-tab-content"> <div class="layui-tab-item layui-show">內(nèi)容1</div> <div class="layui-tab-item">內(nèi)容2</div> <div class="layui-tab-item">內(nèi)容3</div> <div class="layui-tab-item">內(nèi)容4</div> <div class="layui-tab-item">內(nèi)容5</div> </div> </div> <div class="site-demo-button" > <button class="layui-btn site-demo-active" data-type="tabAdd">新增Tab項</button> <button class="layui-btn site-demo-active" data-type="tabDelete">刪除:商品管理</button> <button class="layui-btn site-demo-active" data-type="tabChange">切換到:用戶管理</button> </div> </div> </div> </div> <!-- 注意:如果你直接復(fù)制所有代碼到本地,上述js路徑需要改成你本地的 --> <script> layui.use('element', function () { var $ = layui.jquery , element = layui.element; //Tab的切換功能,切換事件監(jiān)聽等,需要依賴element模塊 //觸發(fā)事件 var active = { tabAdd: function () { //新增一個Tab項 element.tabAdd('demo', { title: '新選項<i class="layui-icon layui-unselect layui-tab-close">ဆ</i>' //用于演示 , content: '內(nèi)容' + (Math.random() * 1000 | 0) , id: new Date().getTime() //實(shí)際使用一般是規(guī)定好的id,這里以時間戳模擬下 }); //增加點(diǎn)擊關(guān)閉事件 var r = $(".layui-tab-title").find("li"); //每次新打開tab都是最后一個,所以只對最后一個tab添加點(diǎn)擊關(guān)閉事件 r.eq(r.length - 1).children("i").on("click", function () { alert($(this).parent("li").attr('lay-id')); element.tabDelete("demo", $(this).parent("li").attr('lay-id')); }), element.tabChange("demo", r.length - 1); element.init(); } , tabDelete: function (othis) { //刪除指定Tab項 element.tabDelete('demo', '44'); //刪除:“商品管理” othis.addClass('layui-btn-disabled'); } , tabChange: function () { //切換到指定Tab項 element.tabChange('demo', '22'); //切換到:用戶管理 } }; $('.site-demo-active').on('click', function () { var othis = $(this), type = othis.data('type'); active[type] ? active[type].call(this, othis) : ''; }); //Hash地址的定位 var layid = location.hash.replace(/^#test=/, ''); element.tabChange('test', layid); element.on('tab(test)', function (elem) { location.hash = 'test=' + $(this).attr('lay-id'); }); }); </script> </body> </html>
以上這篇layerui代碼控制tab選項卡,添加,關(guān)閉的實(shí)例就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持創(chuàng)新互聯(lián)。
分享標(biāo)題:layerui代碼控制tab選項卡,添加,關(guān)閉的實(shí)例
瀏覽地址:http://vcdvsql.cn/article24/jhjece.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供外貿(mào)網(wǎng)站建設(shè)、移動網(wǎng)站建設(shè)、網(wǎng)站排名、Google、定制網(wǎng)站、App開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)