JQuery を使用して、順序付けられていないリストで ListItems の値を取得しようとしています (以下を参照)。以下のコードはほとんど機能していますが、2 番目の ListItem がチェックされていても、常に最初の ListItem の値を返します。
<script>
$(document).ready(function () {
$("li").click(function () {
$("input:checked").each(function () {
alert($("label").attr('InnerText'));
});
});
});
</script>
<div>
<ul class="AspNet-CheckBoxList-RepeatDirection-Vertical">
<li class="AspNet-CheckBoxList-Item">
<input id="CheckBoxList1_0" type="checkbox" name="CheckBoxList1$0" value="first1" />
<label for="CheckBoxList1_0">First $30.00</label>
</li>
<li class="AspNet-CheckBoxList-Item">
<input id="CheckBoxList1_1" type="checkbox" name="CheckBoxList1$1" value="second2" />
<label for="CheckBoxList1_1">Second $25.00</label>
</li>
</ul>
</div>