JavaScript
Article
By Sam Deering

jQuery get element ids list using jQuery.map()

By Sam Deering

This is a quick example use of the jQuery .map() function. Say for instance you wanted to get a comma-separated list of all checkbox IDs in a form, you can do this! Check out the quick demo at https://jsfiddle.net/CEcgL/.

$(':checkbox').map(function() {
  return this.id;
}).get().join(',');

Official jQuery.map() Doco

--ADVERTISEMENT--

Recommended
Sponsors
The most important and interesting stories in tech. Straight to your inbox, daily. Get Versioning.
Login or Create Account to Comment
Login Create Account