欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

ASP.NET jQuery 實(shí)例5 (顯示CheckBoxList成員選中的內(nèi)容)

 更新時(shí)間:2012年01月13日 22:32:19   作者:  
這章我們主要看下如何通過(guò)jQuery來(lái)獲取CheckBoxList成員內(nèi)容
界面代碼:
復(fù)制代碼 代碼如下:

<form id="form1" runat="server">
<div align="left">
<fieldset style="width: 400px; height: 150px">
<p>
請(qǐng)選擇語(yǔ)言</p>
<asp:CheckBoxList ID="ckbListPro" runat="server">
<asp:ListItem Value="1" Text="C#"></asp:ListItem>
<asp:ListItem Value="2" Text="JAVA"></asp:ListItem>
<asp:ListItem Value="3" Text="C++"></asp:ListItem>
<asp:ListItem Value="4" Text="JavaScript"></asp:ListItem>
</asp:CheckBoxList>
</fieldset>
<br />
<div id="message" style="color:Red;"></div>
</div>
</form>

顯示效果:

實(shí)現(xiàn)選中語(yǔ)言并顯示內(nèi)容腳本代碼:
復(fù)制代碼 代碼如下:

<script src="Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
// CheckBoxList在頁(yè)面呈現(xiàn)時(shí)轉(zhuǎn)換為<table id="ckbListPro">
// 成員ListItem轉(zhuǎn)換為<input type="checkbox"><label>
$("#<%=ckbListPro.ClientID %>").click(function () {
var str = "";
// 這里獲取到被選中的<input type="checkbox">
$("#<%=ckbListPro.ClientID %> input[type=checkbox]:checked").each(function () {
str = str + $(this).val() + ":" + $(this).next().text() + " "; // 這里的next()表示<label>
});
$("#message").text(str);
});
});
</script>

選中語(yǔ)言后界面:

相關(guān)文章

最新評(píng)論