JavaScript
Article

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

  • Geovane Gomes

    I loved it so much! Thank you!

Recommended

Learn Coding Online
Learn Web Development

Start learning web development and design for free with SitePoint Premium!

Get the latest in JavaScript, once a week, for free.