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

ASP.NET jQuery 實(shí)例7 通過(guò)jQuery來(lái)獲取DropDownList的Text/Value屬性值

 更新時(shí)間:2012年02月03日 16:52:00   作者:  
這節(jié)我們將通過(guò)jQuery來(lái)獲取DropDownList的Text/Value屬性值,需要的朋友可以參考下
界面代碼:
復(fù)制代碼 代碼如下:

<form id="form1" runat="server">
<div align="center">
<fieldset style="width: 400px; height: 80px;">
<p>
選擇顏色:</p>
<asp:DropDownList ID="ddlColor" runat="server">
<asp:ListItem Text="--- 請(qǐng)選擇 ---" Value=""></asp:ListItem>
<asp:ListItem Text="紅色" Value="1"></asp:ListItem>
<asp:ListItem Text="黃色" Value="2"></asp:ListItem>
<asp:ListItem Text="藍(lán)色" Value="3"></asp:ListItem>
</asp:DropDownList>
</fieldset>
</div>
<br />
<div align="center" id="message">
</div>
</form>

腳本代碼:
復(fù)制代碼 代碼如下:

<script src="Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
// 綁定keyup和change事件
$("#<%=ddlColor.ClientID %>").bind("keyup change", function () {
if ($(this).val() != "") {
// 這里需要注意,$(this).text()獲取的是整個(gè)集合的text屬性內(nèi)容,所以需要再過(guò)濾下,把選中的項(xiàng)取出來(lái)
$("#message").text("Text: " + $(this).find(":selected").text() + "Value: " + $(this).val());
}
else {
$("#message").text("");
}
});
});
</script>

選擇一種顏色顯示如下:

相關(guān)文章

最新評(píng)論