从jQuery对象获取值数组 [英] Getting array of values from jQuery object
本文介绍了从jQuery对象获取值数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下对象:
$("input:checkbox:checked")
[
<input class="li_checker" type="checkbox" category_uid="1.3" category_language="da">,
<input class="li_checker" type="checkbox" category_uid="1.3.1" category_language="da">
]
如果jQuery中有任何帮助程序允许我获取所有元素的"category_uid"值并将其作为另一个数组返回?预期结果:
If there is any helper in jQuery which allows me to get value of "category_uid" for all elements and returns it as the another array? Expected result:
["1.3", "1.3.1"]
推荐答案
使用 map()
:
var myArray = $("input:checkbox:checked").map(function(){
return this.getAttribute("category_uid");
}).get();
这篇关于从jQuery对象获取值数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文