下面我有这个小清单:
<ul id="selectable">
<li id='0'></li>
<li id='1'></li>
<li id='2'></li>
<li id='3'></li>
<li id='4'></li>
</ul>
<span>You've selected:</span>
<span id="select-result">none</span>.
结合jQuery,它应该得到被id
选元素的:
<script>
$(function() {
$( "#selectable" ).selectable({
stop: function() {
var result = $( "#select-result" ).empty();
$( ".ui-selected", this ).each(function() {
var index = $( "#selectable li" ).attr( 'id' );
result.append( index );
});
}
});
});
</script>
每次,我单击一个元素,它都会显示:0
为什么?当我第二次单击列表元素时,它应该显示:1
等,我做错了什么?