e.g.
<div class="myclass" id="div_1"></div>
<div class="myclass" id="div_2"></div>
<div class="notmyclass" id="div_3"></div>
I'd like to end up with array something like ["div_1","div_2"]
After selecting $(".myclass"), you can use the .map() method [docs] to take the .id of each element. This will return a jQuery array-like object containing the ids.
var ids = $(".myclass").map(function() { return this.id; });
Add .toArray() [docs] to the end if you need a real array.
var IDs = [];
$('.myclass').each(function(){
    IDs.push( this.id );
});
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With