is there a way to get all the unique values for a certain attribute.
e.g
<div class="bob" data-xyz="fish"></div>
<div class="bob" data-xyz="dog"></div>
<div class="bob" data-xyz="fish"></div>
<div class="bob" data-xyz="cat"></div>
<div class="bob" data-xyz="fish"></div>
I need to get all the distinct values for data-xyz attribute on div.bob,
so it should return fish, dog and cat.
Small code: Create an object and make ‘dog’ ‘fish’ ‘cat’ properties. That will make them unique. Then get the unique property names from the object. Simple and easy:
http://jsfiddle.net/GxxLj/1/