I can use attr
to "Get the value of an attribute for the first element in the set of matched elements ..."
To get the list of attributes, do I need to build it up manually with $(..).each
or is there a convenience?
$('tr.food-row')
[
<tr class="food-row" data-pk="11457">…</tr>
,
<tr class="food-row" data-pk="11429">…</tr>
]
$('tr.food-row').attr('data-pk')
"11457"
I want to get ["11457", "11429"]
.
var allAttributes = $('tr.food-row').map(function(){
return $(this).data('pk');
}).get();
Live DEMO
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