Programming Tips - How can get the id of every element using a certain class (using jQuery)?

Date: 2009dec16 Language: javaScript Library: jQuery Q. How can get the id of every element using a certain class (using jQuery)? A. This is the kind of thing jQuery was made for. Here is a function that returns an array of id of all elements using a certain class.
function getIds(selector) { var a = []; $(selector).each(function() { a.push(this.id); }); return a; } function exampleUse() { var a, i; a = getIds('.myclass'); for (i = 0; i < a.length; i++) { document.writeln('id: ' + a[i] + '<br>'); } }