Select the ids from an array of jquery elements

With the following jquery statement I select an array of elements:

selectedSupplierIds = $('.supplierListCheckbox: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?

Answers


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();

Need Your Help

Return to last fragment through ActionBar

android android-fragments android-actionbar android-tabs

There are 3 tabs in my ActionBar which for 3 different fragments: Fragment1, Fragment2 and Fragment 3. There is a ListView in Fragment2 which will start a new activity when a row in the list view is

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.