如何循环获取这个span里的data
1个回答
展开全部
<li class='type_Label_Items'>
<span data-id='1'>aaa</span><span>1</span><span>2</span>
</li>
<li class='type_Label_Items'>
<span data-id='2'>aaa</span><span>1</span><span>2</span>
</li>
<li class='type_Label_Items'>
<span data-id='3'>aaa</span><span>1</span><span>2</span>
</li>
<script src=scripts/jquery-1.8.3.min.js></script>
<script>
/* jQuery */
$(function() {
$('.type_Label_Items').each(function() {
alert($(this).find('[data-id]').attr('data-id'));
})
//或
$('.type_Label_Items [data-id]').each(function() {
alert($(this).attr('data-id'));
})
});
</script>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询