Select the ids from an array of jquery elements
With the following jquery statement I select an array of elements:
selectedSupplierIds = $('.supplierListCheckbo开发者_运维问答x:checked');
I need to select the ids from these elements. Can I do this without creating an array and pushing the ids in a for loop?
You can use .map()
to get an array of anything based on your object selection...in this case your just want the .id
property from each, like this:
var arr = $('.supplierListCheckbox:checked').map(function() {
return this.id;
}).get();
精彩评论