Given the following markup, how can I return with jQuery all the data-foo
values with the class .bar
?
<ul id="foobar-list">
<li data-foo="1">Alpha</li>
<li data-foo="2" class="bar">Beta</li>
<li data-foo="3" class="bar">Gamma</li>
<li data-foo="4">Delta</li>
</ul>
Here's my progress so far:
var arr = [];
$('#foobar-list .bar').each(function() {
var arr[] = $(this).data('foo');
});