jQuery获取被嵌套的data属性值

<ul id="getSupListByMerchant">

<li><a href="javaScript:;" data-nameid = 1>
<div class="strip"><span></span><span></span><span></span><span></span></div>
<span>${val.supervision.name}</span><span>监管中</span><span class="glyphicon glyphicon-menu-right"></span>
</a></li>

<li><a href="javaScript:;" data-nameid = 2>
<div class="strip"><span></span><span></span><span></span><span></span></div>
<span>${val.supervision.name}</span><span>监管中</span><span class="glyphicon glyphicon-menu-right"></span>
</a></li>

 

</ul>

// 获取列表第一个id
let listId = $("#getSupListByMerchant li").first().children().data("nameid");
console.log(listId)

 

posted @ 2019-10-27 15:19  小丶鱼  阅读(334)  评论(0编辑  收藏  举报