<label>s
我正在尝试根据一组元素及其 id 属性以我的形式找到一堆。
例如。[ input#country , input#other-country ]
将能够找到<label for="country"> , <label for="other-country">
等等......</p>
到目前为止,我有这个代码:
var LOCATION = {};
LOCATION.option = form.find('input[name=location]').toArray();
LOCATION.labels = [
$.each( LOCATION.option, function(i, input) {
$('label[for='+input.id+']');
})
];
注销循环input.id
内部时,$.each
我得到了正确的值被写出但是我似乎无法找到一种方法将我的匹配label
元素从$.each
循环内部写入LOCATION.labels
数组。
有谁知道如何将它们放入数组中?toArray()
似乎也不起作用……</p>
谢谢阅读。