jquery判斷RadioButtonList和RadioButton中是否有選中項(xiàng)示例
更新時(shí)間:2013年09月29日 16:21:55 作者:
用jquery判斷RadioButtonList和RadioButton中是否有選中項(xiàng),下面有個(gè)不錯(cuò)的示例,感興趣的朋友可以參考下
復(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”,若有選中的,則彈出對(duì)應(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; //暫時(shí)不用傳到后臺(tái)
}
</script>
</pre>
您可能感興趣的文章:
- jQuery中的RadioButton,input,CheckBox取值賦值實(shí)現(xiàn)代碼
- asp.net使用jQuery獲取RadioButtonList成員選中內(nèi)容和值示例
- 基于jquery自定義的漂亮單選按鈕RadioButton
- jQuery中RadioButtonList的功能及用法實(shí)例介紹
- Jquery中的CheckBox、RadioButton、DropDownList的取值賦值實(shí)現(xiàn)代碼
- JQuery中對(duì)服務(wù)器控件 DropdownList, RadioButtonList, CheckboxList的操作總結(jié)
- jquery獲取ASP.NET服務(wù)器端控件dropdownlist和radiobuttonlist生成客戶端HTML標(biāo)簽后的value和text值
- jQuery實(shí)現(xiàn) RadioButton做必選校驗(yàn)功能
相關(guān)文章
jquery.jsPlumb實(shí)現(xiàn)拓?fù)鋱D
這篇文章主要為大家詳細(xì)介紹了jquery.jsPlumb實(shí)現(xiàn)拓?fù)鋱D,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-03-03Jquery焦點(diǎn)與失去焦點(diǎn)示例應(yīng)用
這篇文章主要介紹了Jquery焦點(diǎn)與失去焦點(diǎn)示例應(yīng)用,需要的朋友可以參考下2014-06-06基于DOM節(jié)點(diǎn)刪除之empty和remove的區(qū)別(詳解)
下面小編就為大家?guī)硪黄贒OM節(jié)點(diǎn)刪除之empty和remove的區(qū)別(詳解)。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-09-09jquery插件splitScren實(shí)現(xiàn)頁面分屏切換模板特效
這篇文章主要介紹了jquery插件splitScren實(shí)現(xiàn)頁面分屏切換模板特效的相關(guān)資料,需要的朋友可以參考下2015-06-06jQuery學(xué)習(xí)筆記之jQuery.extend(),jQuery.fn.extend()分析
給jQuery做過擴(kuò)展或者制作過jQuery插件的人這兩個(gè)方法東西可能不陌生. jQuery.extend([deep],target,object1,,object2...[objectN]) jQuery.fn.extend([deep],target,object1,,object2...[objectN]) 這兩個(gè)屬性都是用于合并兩個(gè)或多個(gè)對(duì)象的屬性到target對(duì)象.2014-06-06