如何使用JavaScript查找单选按钮 [英] How to find Radio buttons using javascript
本文介绍了如何使用JavaScript查找单选按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的部分页面上有多个单选按钮,同一页面上也有一个按钮
我正在像这样分配单选按钮
I have mutiple radio buttons on my partial page, I also have one button on the same page
I am assigning radio button like this
var rbSeq = 1;
foreach(var item in Model){
@Html.RadioButtonFor(modelItem => item.YesNoNA[rbSeq], "true", new { id = "rb_YesNotrue" + rbSeq })
rbSeq++;
}
现在单击按钮",我想找到所有单选按钮元素.
谢谢,
Rachana
Now on click of Button I want to find all the radio button elements.
Thanks,
Rachana
推荐答案
,您可以使用 jquery 轻松找到所有单选按钮:
you can easily find all radio buttons using jquery:
(' input [type ="radio]').each();
('input[type="radio"]').each();
因此,如果您想在单击按钮后对单选按钮执行某些操作,则:
So if you want to do something with your radiobuttons after clicking a button then:
<asp:button id="myButton" runat="server" onclientclick="doSomWork()" />
<script type="text/javascript">
function doSomeWork(){
(' input [type ="radio"]').each( function (){ // 迭代所有单选按钮 var radioButton =
('input[type="radio"]').each(function(){ // iterates all radio buttons var radioButton =
这篇关于如何使用JavaScript查找单选按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文