可以't使用jquery获取单选按钮的值
Can't get value of radio buttons using jquery
我有一系列单选按钮和一个提交按钮:
<input type="radio" name="selectme_resubmit" id="selectme_resubmit1" value="first" /> <label for="selectme_resubmit1">Resubmit with the original submitter</label><br>
<input type="radio" name="selectme_resubmit" id="selectme_resubmit2" value="without" checked /> <label for="selectme_resubmit2">Resubmit without any submitter</label><br>
<input type="radio" name="selectme_resubmit" id="selectme_resubmit3" value="custom" /> <label for="selectme_resubmit3">Resubmit with a custom submitter:</label> <input type="text" name="selectme_custom_submitter" id="selectme_custom_submitter" /><br>
<input type="button" id="selectme_resubmit_button" name="selectme_resubmit2_button" value="Place a submit template" onclick="selectme_act(''resubmit'')" />
我还有以下javascript(带有jquery):
var typeofsubmit = $("input[name=selectme_resubmit]:checked").val();
console.log(typeofsubmit);
然而,我在控制台中得到了"未定义",即使我选择了一些东西。。。我做错了什么?
我测试了您的代码,选择器确实工作了。我发现的唯一问题是,当onclick
事件中不需要'
字符时,您正在转义该字符
您错过了就绪功能
$().ready(function(){
var typeofsubmit = $("input[name=selectme_resubmit]:checked").val();
console.log(typeofsubmit);
});
请在申报之前使用就绪功能
并检查此链接http://jsfiddle.net/FQGuu/
相关文章:
- 通过ajax到php文件获取单选按钮值
- 如何获取单选按钮的多个实例的选定单选按钮值
- 如何在jQuery中获取单选按钮组的值
- 如何在不使用jQuery的情况下设置数组以获取单选按钮值
- 如何使用 ajax 从 sql Server 获取单选按钮的值,并表示列表单选按钮
- 获取单选按钮元素的span子项
- 如何正确获取单选按钮值
- 我可以't获取单选按钮上的onclick属性以执行javascript函数
- Jquery获取单选按钮旁边文本框的值
- 获取单选按钮的选定值
- CRM 2011 javascript 获取单选按钮值并设置用户名
- 使用 jQuery 获取单选按钮组的值
- AngularJs 指令在更改时获取单选按钮 ng-model 值
- 无法获取单选按钮的值
- 在 php 中的 JavaScript 函数中获取单选按钮字段值
- 单击按钮时获取单选按钮值不起作用angularjs
- 获取单选按钮列表中选中单选按钮的值
- 如何从php中获取单选按钮值
- 可以't使用jquery获取单选按钮的值
- 使用JavaScript获取单选按钮的ID