7
rated 0 times
[
14]
[
7]
/ answers: 1 / hits: 31410
/ 12 Years ago, wed, august 1, 2012, 12:00:00
I have a list here
<ul id=demo2 data-name=demo2>
<li data-value=here>here</li>
<li data-value=are>are</li>
<li data-value=some...>some</li>
<!-- notice that this tag is setting a different value :) -->
<li data-value=initial>initial</li>
<li data-value=tags>tags</li>
</ul>
Where each li item has a custom data attribute. On JQuery how would get all of the values of each li element which has an attribute of data-value? I want to get their value.
but this code of mine doesn't seem to be working
$('#view-tags').click(function(){
$('li[data-value]').each(function(){
alert($(this).data(value));
})
});
The whole code on jsfiddle: http://jsfiddle.net/Zn3JA/
More From » jquery