【发布时间】:2020-01-11 20:29:14
【问题描述】:
我正在尝试收集扇区中的 id 列表(数组)
<div id="mydiv">
<span id='span1'>
<span id='span2'>
</div>
$("#mydiv").find("span");
给了我一个 jQuery 对象,但不是一个真正的数组;
我可以的
var array = jQuery.makeArray($("#mydiv").find("span"));
然后使用for循环将id属性放入另一个数组中
或者我可以做
$("#mydiv").find("span").each(function(){}); //but i cannot really get the id and assign it to an array that is not with in the scope?(or can I)
无论如何,我只是想看看 jQuery 中是否有一个速记来做到这一点;
【问题讨论】:
标签: javascript jquery