I'm trying to grab out an array from a data attribute on a table row.
When I run this it returns an array of objects in which I can view there data attributes
$('#searchresultstable input[type=checkbox]:checked').closest('tr')
Chrome's response:
[
<tr class="mediafilter-1" data-titleid="794">…</tr>,
<tr class="mediafilter-1" data-titleid="891">…</tr>,
<tr class="mediafilter-1" data-titleid="1127">…</tr>,
<tr class="mediafilter-1" data-titleid="1388">…</tr>
]
How ever when I add the data attribute function:
$('#searchresultstable input[type=checkbox]:checked').closest('tr').data('titleid')
Chrome Response: 794
I know I could probably loop through these with an each and grab then out. However, I'd like to know how to do this the short hand way, with out the explicit each. Does anybody know how to grab out these values?
each, or loop of some variety. When you usedataon a selector containing multiple elements only the first element will be read.