如何从选定的单选按钮获取值
how to get value from selected radio button
先生,我有一个表单输入像输入文本和单选按钮。如何获得所选单选按钮的值,并将该值放入输入类型文本。
这里是jsfiddle, https://jsfiddle.net/czw71dfk/2/
<div id="gender" class="form-inline">
<div class="form-group">
<label for="">I Sign up as</label>
<input #id="place" type="text" class="form-control" readonly/>
<div class="radio-inline">
<label class="label_item" for="radioMale">
<input type="radio" class="radio_item" value="male" name="gender" id="radioMale">
</label>
<p class="text-center colorGrey">Male</p>
</div>
<div class="radio-inline">
<label class="label_item" for="radioFemale">
<input type="radio" class="radio_item" value="female" name="gender" id="radioFemale">
</label>
<p class="text-center colorGrey">Female</p>
</div>
<div class="radio-inline">
<label class="label_item" for="radioKids">
<input type="radio" class="radio_item" value="Kids" name="gender" id="radioKids">
</label>
<p class="text-center colorGrey">Kids</p>
</div>
</div>
</div>
$('#gender input').on('change', function() {
var gender = $( this ).val();
$("#place").val( gender );
});
HTML问题#id="place"
And must use on change;
$(document).ready(function(){
$('input[name=gender]').on('change', function() {
var gender = $( this ).val();
$("#place").val( gender );
});
});
JSFiddle.net示例将#id="place"
改为id="place"
https://jsfiddle.net/czw71dfk/4/
<input #id="place" type="text" class="form-control" readonly/>
<input id="place" type="text" class="form-control" readonly/>
相关文章:
- Javascript:无法获取变量中的单选按钮值
- 通过ajax到php文件获取单选按钮值
- 如何获取单选按钮的多个实例的选定单选按钮值
- (extjs)获取表单中单选按钮的选定值.不返回该值
- 如何从单选按钮中获取多个值,然后将它们分配到单个变量中并在页面上显示
- 如何在jQuery中获取单选按钮组的值
- 如何在不使用jQuery的情况下设置数组以获取单选按钮值
- 获取Javascript中单选按钮的true或false
- 如何使用jquery在网格视图中获取所选单选按钮的值
- 从选中的单选按钮获取文本节点
- 如何从人工任务表单中的单选按钮获取检查值
- 从单选按钮获取数据
- 使用带有javascript的单选按钮..获取null错误
- 从多个复选框和单选按钮获取信息
- Javascript从单选按钮获取信息
- 使用jquery从单选按钮获取span价格
- 从输入单选按钮获取平均值
- 谷歌表单脚本-从单选按钮获取值,目前未定义
- 从mdl单选按钮获取值
- 如何从选定的单选按钮获取值