[英]Get selected items from checkbox list with jQuery
如何在jQuery的按鈕單擊事件中獲取checkBoxList的選定項值...
<asp:CheckBoxList ID="check_list" runat="server">
<asp:ListItem Text ="One" Value="1"></asp:ListItem>
<asp:ListItem Text ="Two" Value="2"></asp:ListItem>
<asp:ListItem Text ="Three" Value="3"></asp:ListItem>
</asp:CheckBoxList>
<input type="button" id="btn_click" value="Click"/>
只需使用諸如按鈕之類的屬性選擇器,就可以循環遍歷所有選中的值,例如
$("#btn_click").click(function(){
$("[id*=check_list] input[type=checkbox]:checked").each(function () {
// add $(this).val() to your array
});
});
請參閱API中描述的jQuery :checked
選擇器。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.