<p class="t">
<span class="y" id="A1">A</span>
<span class="y" id="B1">B</span>
<span class="y" id="C1">C</span>
...
</p>
如何获取A1 B1 C1 ... ?
我的思路:
var obj=$('.t').children('.y');
for(var n in obj){
alert(n.attr('id'));
}
貌似不行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
楼主的方法之所以不行是因为你觉得获得是一个对象,但其实是一个数组,所以不应该用for in循环,而是正常的for循环拿值