layui 的nav导航 事件监控,获取DOM元素

<body >

<ul class="layui-nav layui-nav-tree" lay-filter="leftNav">
<li class="layui-nav-item layui-nav-itemed">
<a href="javascript:;"><i class="iconfont">&#xe607;</i>菜单管理</a>
<dl class="layui-nav-child">
<dd><a href="javascript:;" data-url="menu1.html" data-id='1' data-text="后台菜单"><span class="l-line"></span>后台菜单</a></dd>
<dd><a href="javascript:;" data-url="menu2.html" data-id='2' data-text="前台菜单"><span class="l-line"></span>前台菜单</a></dd>
</dl>
</li>

<li class="layui-nav-item">
<a href="javascript:;"><i class="iconfont">&#xe608;</i>内容管理</a>
<dl class="layui-nav-child">
<dd><a href="javascript:;" data-url="article-list.html" data-id='3' data-text="文章管理"><span class="l-line"></span>文章管理</a></dd>
<dd><a href="javascript:;" data-url="danye-list.html" data-id='9' data-text="单页管理"><span class="l-line"></span>单页管理</a></dd>
</dl>
</li>
</ul>


<script src="static/layui.js" type="text/javascript" charset="utf-8"></script>
<script src="static/xqb_js/common.js" type="text/javascript" charset="utf-8"></script>
<script>
layui.use(['form', 'layedit', 'laydate','element','jquery'], function() {
var form = layui.form,
layer = layui.layer,
element=layui.element,
$=layui.jquery;
 
element.on('nav(leftNav)', function(elem) {
        
        var id = elem.attr('data-id');
        var url = elem.attr('data-url');
        var text = elem.attr('data-text');
 
console.log(text);

     });

 
});
</script>

</body>
posted @ 2018-06-20 16:47  阿强是小兵  阅读(18052)  评论(1编辑  收藏  举报