jquery判斷RadioButtonList和RadioButton中是否有選中項示例
更新時間:2013年09月29日 16:21:55 作者:
用jquery判斷RadioButtonList和RadioButton中是否有選中項,下面有個不錯的示例,感興趣的朋友可以參考下
復制代碼 代碼如下:
<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>
復制代碼 代碼如下:
<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”,若有選中的,則彈出對應的 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成員選中內容和值示例
- 基于jquery自定義的漂亮單選按鈕RadioButton
- jQuery中RadioButtonList的功能及用法實例介紹
- Jquery中的CheckBox、RadioButton、DropDownList的取值賦值實現(xiàn)代碼
- JQuery中對服務器控件 DropdownList, RadioButtonList, CheckboxList的操作總結
- jquery獲取ASP.NET服務器端控件dropdownlist和radiobuttonlist生成客戶端HTML標簽后的value和text值
- jQuery實現(xiàn) RadioButton做必選校驗功能
相關文章
jQuery實現(xiàn)table表格信息的展開和縮小功能示例
這篇文章主要介紹了jQuery實現(xiàn)table表格信息的展開和縮小功能,涉及jQuery事件響應及頁面元素遍歷、屬性修改相關操作技巧,需要的朋友可以參考下2018-07-07
使用微信內置瀏覽器點擊下拉框出現(xiàn)頁面亂跳轉現(xiàn)象(iphone),該怎么辦
這篇文章主要介紹了使用微信內置瀏覽器點擊下拉框出現(xiàn)頁面亂跳轉現(xiàn)象(iphone),該怎么辦的相關資料,需要的朋友可以參考下2016-01-01
jquery分頁插件jquery.pagination.js使用方法解析
這篇文章主要針對js分頁插件jquery.pagination.js使用方法進行解析,很實用的分頁插件,感興趣的小伙伴們可以參考一下2016-04-04
jquery Ajax 實現(xiàn)加載數(shù)據(jù)前動畫效果的示例代碼
本篇文章主要是對jquery Ajax實現(xiàn)加載數(shù)據(jù)前動畫效果的示例代碼進行了介紹,需要的朋友可以過來參考下,希望對大家有所幫助2014-02-02

