i want to read out the value of List item and write it into span.
So that the lists looks like this:
- my first item (1)
- another item (2)
- next item (3)
- my first item (a)
- another item (b)
- next item (c)
但一心发现错误:
<div id="Listgroup">
<ul id="list1">
<li><a href="" value="1">my first item<span></span></a></li>
<li><a href="" value="2">another item<span></span></a></li>
<li><a href="" value="3">next item<span></span></a></li>
</ul>
<br>
<ul id="list2">
<li><a href="" value="a">my first item<span></span></a></li>
<li><a href="" value="b">another item<span></span></a></li>
<li><a href="" value="c">next item<span></span></a></li>
</ul>
</div>
<script>
$(function(){
$("li a").each(function(idx, item){
$("span", "li a[value|= + $(this).attr( value ) + ]")
.html(" (" + $(this).attr( value ) + ")");
});
});
</script>
帮助
谢谢。