个人代码1:

<div class="form-group" style="width: 250px;margin:0 auto;">

<label for="">性别</label>

<input type="radio" id="driverSex" name="driverSex" value="男"/>男

<input type="radio" id="driverSex" name="driverSex" value="女"/>女

</div>

注意: 1.value属性不要写错,写错或没写会获取的值默认是on

2.name 属性必须一致

个人代码2:

//编辑

function editdriver(id) {

$.ajax({

url:"${pageContext.request.contextPath}/upadatedriver",

type:"GET",

data:{"id":id},

success:function(result){

console.log(result);

$("input[name=driverSex]").val([result.driverSex]);//回显性别

}

});

$("#driver").modal("show");//打开模态框

}

其他参考:

1.获取选中值,三种方法都可以:
$('input:radio:checked').val();
$("input[type='radio']:checked").val();
$("input[name='rd']:checked").val();
2.设置第一个Radio为选中值:
$('input:radio:first').attr('checked', 'checked');
或者
$('input:radio:first').attr('checked', 'true');
注:attr("checked",'checked')= attr("checked", 'true')= attr("checked", true)
3.设置最后一个Radio为选中值:
$('input:radio:last').attr('checked', 'checked');
或者
$('input:radio:last').attr('checked', 'true');
4.根据索引值设置任意一个radio为选中值:
$('input:radio').eq(索引值).attr('checked', 'true');索引值=0,1,2....

获取input type=radio属性的value值的更多相关文章

  1. 获取<input type="radio">被选中的内容

    背景: <input type="radio">,该标签表示的是单选按钮,这个类型相对于其他类型的获取,比较特殊,特此记录一下. 获取方式: 1. 使用选择器直接获取( ...

  2. jquery 获取 input type radio checked的元素

    .find('input:radio:checked'):.find("input[type='radio']:checked");.find("input[name=' ...

  3. <input type="radio" >与<input type="checkbox">值得获取

    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"% ...

  4. 工作总结 js 选择器选择多条元素 支持一起设置他们属性 $("#edumes input[type='radio']").prop("checked", false);

    $("#edumes input[type='radio']").prop("checked", false); $("#edumes input[t ...

  5. jQuery操作<input type="radio">

    input type="radio">如下: <input type="radio" name="city" value=&qu ...

  6. asp.mvc获取checkbox、radio、select的值

    记录一下在asp.mvc中,提交表单时后台获取checkbox.radio.select值的方法. 1.获取select的值 <select name="type"> ...

  7. jquery attr方法和prop方法获取input的checked属性问题

    jquery attr方法和prop方法获取input的checked属性问题   问题:经常使用jQuery插件的attr方法获取checked属性值,获取的值的大小为未定义,此时可以用prop方法 ...

  8. 获取input type=file 的文件内容(纯文本)

    一.获取input type=file 的文件内容(纯文本) 1.需求一 通过点击其他事件,来触发 文件选择框(限定格式为 .c 文件),而不是手动鼠标点击触发. [思路:] step1:将 inpu ...

  9. Jquery给input[type=radio] 控件赋值

    setobject: function (data, scope, win) { //data jsoon数据, scope,一般为form的id,win 窗口对象,如果在当前window win=n ...

随机推荐

  1. Having用法以及其和Where区别

    例如,进行分组语句: select year,count(id) num from tblPlantProduce group by year 在这条语句中若要筛选出年份>2005年的有两种方式 ...

  2. 洛谷P1327 数列排序

    https://www.luogu.org/problem/P1327 #include<bits/stdc++.h> #define Ll long long using namespa ...

  3. rancher版本问题引发的节点注册失败失败

    rancher版本问题引发的节点注册失败失败 待办 https://www.cnblogs.com/Me1onRind/p/11147639.html

  4. goahead 流程

    原文:https://blog.csdn.net/qq_32419007/article/details/80756643 1.全局变量 Web服务器的根目录 static char_t        ...

  5. HDU 6740 kmp最小循环节

    题意:给一个无线循环小数的前几位,给n,m 选择其中一种出现在前几位的循环节方式(a个数),循环节的长度b 使得n*a-m*b最大 样例: 2 1 12.1212 输出 6 选择2,2*1-1*1=1 ...

  6. PHP SDK+Oss 上传文件流

    // Endpoint以杭州为例,其它Region请按实际情况填写. $endpoint = "http://oss-cn-hangzhou.aliyuncs.com"; // 云 ...

  7. 每天进步一点点------Allegro 群组布线

    执行Route->connect命令,设置好控制面板中的内容.然后设置同时走线的GROUP包含哪些网络,有两种方法.第一种方法,如果几个网络是紧邻的,可以直接框选,选中的网络就会被包含在GROU ...

  8. DFT 问答 II

    1. Boundary Scan A:Boundary scan 顾名思义,是附加在芯片I/O 周边的扫描测试链,它通过专门的测试端口(TAP)访问.在测试模式下,边界扫描链会接管功能逻辑,对I/O进 ...

  9. Vue - 过渡 列表过渡

    列表的进入/离开过渡 获取不大于数组长度的随机数,作为插入新值的位置 <div id="app" class="demo"> <button ...

  10. 吴裕雄 python 机器学习——数据预处理过滤式特征选取VarianceThreshold模型

    from sklearn.feature_selection import VarianceThreshold #数据预处理过滤式特征选取VarianceThreshold模型 def test_Va ...