I have list like this.
<li data-pet="cat"></li>
<li data-pet="cat"></li>
<li data-pet="cat"></li>
<li data-pet="dog"></li>
Using jQuery how can I grab the value of the data-attributes to count if the same value appears more than once.
I then want to append a span to first list element with that value.
Result should look like this.
<li data-pet="cat"><span class="first"></span></li>
<li data-pet="cat"></li>
<li data-pet="cat"></li>
<li data-pet="dog"></li>
Thanks for your help.
a possible implementation
html
Example fiddle: http://jsfiddle.net/HJ6gF/6/