jquery判斷RadioButtonList和RadioButton中是否有選中項示例
更新時間:2013年09月29日 16:21:55 作者:
用jquery判斷RadioButtonList和RadioButton中是否有選中項,下面有個不錯的示例,感興趣的朋友可以參考下
復(fù)制代碼 代碼如下:
<pre class="html" name="code"> <%--Body 代碼--%>
<div>
<asp:RadioButtonList ID="RadioButtonList1" runat="server">
<asp:ListItem Value="A">a</asp:ListItem>
<asp:ListItem Value="B">b</asp:ListItem>
</asp:RadioButtonList>
<asp:RadioButton ID="RadioButton1" GroupName="RBtn" Text="男" runat="server" Checked="true" />
<asp:RadioButton ID="RadioButton2" GroupName="RBtn" Text="女" runat="server" />
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="Button1_ClientClick()"></asp:Button>
</div></pre>
復(fù)制代碼 代碼如下:
<pre class="csharp" name="code"><%--Head 代碼--%>
<script language="javascript" type="text/javascript" src="js/jquery-1.9.1.js"></script>
<script language="javascript" type="text/javascript">
function Button1_ClientClick()
{
alert($("input[name='RadioButtonList1']:checked").val()); // 若都沒有選中,則彈出“undefined”,若有選中的,則彈出對應(yīng)的 Value 值
if(document.getElementById("RadioButton1").checked==true) // 若RadioButton1被選中
{
alert($("#RadioButton1:checked").val()); //彈出 RadioButton1
alert($("#RadioButton2:checked").val()); //彈出 undefined
alert($("#RadioButton1:checked").val()=="RadioButton1"); //彈出 true
}
return false; //暫時不用傳到后臺
}
</script>
</pre>
您可能感興趣的文章:
- jQuery中的RadioButton,input,CheckBox取值賦值實現(xiàn)代碼
- asp.net使用jQuery獲取RadioButtonList成員選中內(nèi)容和值示例
- 基于jquery自定義的漂亮單選按鈕RadioButton
- jQuery中RadioButtonList的功能及用法實例介紹
- Jquery中的CheckBox、RadioButton、DropDownList的取值賦值實現(xiàn)代碼
- JQuery中對服務(wù)器控件 DropdownList, RadioButtonList, CheckboxList的操作總結(jié)
- jquery獲取ASP.NET服務(wù)器端控件dropdownlist和radiobuttonlist生成客戶端HTML標(biāo)簽后的value和text值
- jQuery實現(xiàn) RadioButton做必選校驗功能
相關(guān)文章
基于DOM節(jié)點刪除之empty和remove的區(qū)別(詳解)
下面小編就為大家?guī)硪黄贒OM節(jié)點刪除之empty和remove的區(qū)別(詳解)。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-09-09jquery插件splitScren實現(xiàn)頁面分屏切換模板特效
這篇文章主要介紹了jquery插件splitScren實現(xiàn)頁面分屏切換模板特效的相關(guān)資料,需要的朋友可以參考下2015-06-06jQuery學(xué)習(xí)筆記之jQuery.extend(),jQuery.fn.extend()分析
給jQuery做過擴展或者制作過jQuery插件的人這兩個方法東西可能不陌生. jQuery.extend([deep],target,object1,,object2...[objectN]) jQuery.fn.extend([deep],target,object1,,object2...[objectN]) 這兩個屬性都是用于合并兩個或多個對象的屬性到target對象.2014-06-06