zoukankan      html  css  js  c++  java
  • Jquery 操作 radio选中值

    1.获取radio选中值

    1.1  $('input:radio:checked').val();

    1.2  $("input[type='radio']:checked").val();

    1.3  $("input[name='rd']:checked").val();

     

    2. 设置radio选中值

    2.1 $('input:radio:first').attr('checked', 'checked'); //设置第一个Radio为选中值

    2.2 $('input:radio:last').attr('checked', 'checked');  或者 $('input:radio:last').attr('checked', 'true'); //设置最后一个Radio为选中值  注:attr("checked",'checked')= attr("checked", 'true')= attr("checked", true)

    2.3 $('input:radio').eq(索引值).attr('checked', 'true'); //根据索引值设置任意一个radio为选中值

    2.4 $("input:radio[value='1']").attr('checked','true'); //根据Value值设置Radio为选中值

    2.5 $("input[type=radio][name='region'][value='1']").attr("checked",'checked');//根据Value值和name值 设置Radio为选中值

    2.6 $("#form1  input:radio[name='radio1'][value='1']").prop('checked','true'); //根据Value值设置 指定表单中 名称为radio1 的 Radio

     

    3 删除radio值

    3.1 $("input:radio[value='rd2']").remove();  //删除Value值为rd2的Radio

    3.2 $("input:radio").eq(索引值).remove(); //删除第几个Radio

     

    4 遍历操作radio 值

    $('input:radio').each(function(index,domEle){

         //写入代码

    });

     

  • 相关阅读:
    HQueue_Install_In_Ubuntu
    win10_64_ssh连接linux
    win10防火墙服务灰色解决办法
    打开houdini软件的脚本
    houdini_license_sever start and off
    Java关于Object类中equal方法的理解
    Java关于Object类中equal方法的理解
    单源最短路径
    单源最短路径
    最小生成树
  • 原文地址:https://www.cnblogs.com/xiaonanmu/p/4160030.html
Copyright © 2011-2022 走看看