Grab values of an attribute from all elements in jQuery
You can use something like that: https://jsfiddle.net/g903dyp6/
<entries>
<entry id="1" />
<entry id="2" />
<entry id="3" />
<entry id="4" />
</entries>
let arr = $.map($('entry'), function(el) {
return $(el).attr('id');
});
There is not a direct function to do that. However, it can be easily accomplished using .map(). E.g.,
let ids = $('entry').map(function() {
return this.getAttribute('id');
}).get();
let ids = $('entry').map(function() {
return this.getAttribute('id');
}).get();
console.log(ids);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<entries>
<entry id="1" />
<entry id="2" />
<entry id="3" />
<entry id="4" />
</entries>