我有两个单选按钮,想要发布所选的一个值.如何通过jQuery获取值?
我可以像这样得到所有这些:
$("form :radio")
Run Code Online (Sandbox Code Playgroud)
我如何知道选择了哪一个?
我尝试用jQuery检查一个单选按钮.这是我的代码:
<form>
<div id='type'>
<input type='radio' id='radio_1' name='type' value='1' />
<input type='radio' id='radio_2' name='type' value='2' />
<input type='radio' id='radio_3' name='type' value='3' />
</div>
</form>
Run Code Online (Sandbox Code Playgroud)
和JavaScript:
jQuery("#radio_1").attr('checked', true);
Run Code Online (Sandbox Code Playgroud)
不起作用:
jQuery("input[value='1']").attr('checked', true);
Run Code Online (Sandbox Code Playgroud)
不起作用:
jQuery('input:radio[name="type"]').filter('[value="1"]').attr('checked', true);
Run Code Online (Sandbox Code Playgroud)
不起作用:
你有其他想法吗?我错过了什么?
我有一些单选按钮,我希望在加载页面时默认将其中一个设置为选中状态.我怎样才能做到这一点?
<input type="radio" name="imgsel" value="" />
Run Code Online (Sandbox Code Playgroud) 问题陈述很简单.我需要查看用户是否从广播组中选择了一个单选按钮.组中的每个单选按钮共享相同的ID.
问题是我无法控制表单的生成方式.以下是单选按钮控件代码的示例代码:
<input type="radio" name='s_2_1_6_0' value='Mail copy to my bill to address' id = "InvCopyRadio" onchange = 'SWESubmitForm(document.SWEForm2_0,s_4,"","1-DPWJJF")' style="height:20;width:25" tabindex=1997 >
Run Code Online (Sandbox Code Playgroud)
除此之外,当选择单选按钮时,它不会向控件添加"已选中"属性,只是选中 了文本(我猜测只检查了没有值的属性).以下是所选无线电控制的外观
<input type="radio" checked name='s_2_1_6_0' value='Mail copy to my bill to address' id = "InvCopyRadio" onchange = 'SWESubmitForm(document.SWEForm2_0,s_4,"","1-DPWJJF")' style="height:20;width:25" tabindex=1997 >
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮助我使用jQuery代码,可以帮助我获得已检查单选按钮的值吗?
在使用jQuery提交AJAX表单后,我想要取消选中一组单选按钮.我有以下功能:
function clearForm(){
$('#frm input[type="text"]').each(function(){
$(this).val("");
});
$('#frm input[type="radio":checked]').each(function(){
$(this).checked = false;
});
}
Run Code Online (Sandbox Code Playgroud)
在此功能的帮助下,我可以清除文本框中的值,但我无法清除单选按钮的值.
顺便说一句,我也试过$(this).val("");但是没用.
我有这样的枚举:
public enum MyLovelyEnum
{
FirstSelection,
TheOtherSelection,
YetAnotherOne
};
Run Code Online (Sandbox Code Playgroud)
我的DataContext中有一个属性:
public MyLovelyEnum VeryLovelyEnum { get; set; }
Run Code Online (Sandbox Code Playgroud)
我的WPF客户端中有三个RadioButton.
<RadioButton Margin="3">First Selection</RadioButton>
<RadioButton Margin="3">The Other Selection</RadioButton>
<RadioButton Margin="3">Yet Another one</RadioButton>
Run Code Online (Sandbox Code Playgroud)
现在如何将RadioButtons绑定到属性以进行正确的双向绑定?
我只是想知道如何在radiobuttons上正确使用新的HTML5输入属性"required".每个radiobutton字段是否都需要如下所示的属性?或者只有一个领域得到它就足够了吗?
<input type="radio" name="color" value="black" required="required" />
<input type="radio" name="color" value="white" required="required" />
Run Code Online (Sandbox Code Playgroud) 我的网页上有3个单选按钮,如下所示:
<label for="theme-grey">
<input type="radio" id="theme-grey" name="theme" value="grey" />Grey</label>
<label for="theme-pink">
<input type="radio" id="theme-pink" name="theme" value="pink" />Pink</label>
<label for="theme-green">
<input type="radio" id="theme-green" name="theme" value="green" />Green</label>Run Code Online (Sandbox Code Playgroud)
在jQuery中,我希望在单击这三个中的任何一个时获取所选单选按钮的值.在jQuery中我们有id(#)和class(.)选择器,但如果我想按名称找到一个单选按钮怎么办,如下所示?
$("<radiobutton name attribute>").click(function(){});
Run Code Online (Sandbox Code Playgroud)
请告诉我如何解决这个问题.
如何在Windows窗体应用程序中对单选按钮进行分组(很像ASP.NET的radiobuttonlist!)?
所以我可以在从选项中选择的每个案例之间切换.
如何使用jQuery设置无线电选项onload?
需要检查是否未设置默认值,然后设置默认值
radio-button ×10
jquery ×6
javascript ×4
html ×3
.net ×1
c# ×1
data-binding ×1
enums ×1
forms ×1
html5 ×1
required ×1
siebel ×1
winforms ×1
wpf ×1