zoukankan      html  css  js  c++  java
  • jquery获取radio值

    单选组radio: $("input[@type=radio][@checked]").val();

    单选组 radio: $("input[@type=radio]").attr("checked",'2');//设置value=2的项目为当前选中项

    获取一组radio被选中项的值
    var item = $('input[@name=items][@checked]').val();

    radio单选组的第二个元素为当前选中值
    $('input[@name=items]').get(1).checked = true

    单选组 radio: $("input[@type=radio]").attr("checked",'2');//设置value=2的项目为当前选中项


    jquery老的版本
    var_name = $("input[@name='radio_name']:checked").val();
    jquery 1.3以后的版本
    var_name = $("input[name='radio_name']:checked").val();


    看个获取radio值的jquery实例

    function getra(){

    var_name = $("input[name='isspecialcnt']:checked").val();
    //alert(var_name);
    if(var_name=='1'){
    $("#isspecialcntyes").show();
    $("#isspecialcntno").hide();
    }
    if(var_name=='0'){
    $("#isspecialcntyes").hide();
    (www.111cn.net) $("#isspecialcntno").show();
    }
    }

    <form name="form1" method="post" action="">
    <p>
    <label>
    <input type="radio" name="radiogroup1" value="单选" id="radiogroup1_0">
    单选</label>
    <br>
    <label>
    <input type="radio" name="radiogroup1" value="单选" id="radiogroup1_1">
    单选</label>
    <br>
    <label>
    <input type="radio" name="radiogroup1" value="单选" id="radiogroup1_2">
    单选</label>
    <br>
    <label>
    <input type="radio" name="radiogroup1" value="单选" id="radiogroup1_3">
    单选</label>
    <br>
    <label>
    <input type="radio" name="radiogroup1" value="单选" id="radiogroup1_4">
    单选</label>
    <br>
    <label>
    <input type="radio" name="radiogroup1" value="单选" id="radiogroup1_5">
    单选</label>
    <br>
    </p>
    </form>
    from:http://www.111cn.net/wy/jquery/jquery-radio.htm

  • 相关阅读:
    String字符串性能优化的探究
    Spring笔记(5)
    Spring笔记(4)
    力扣217. 存在重复元素
    力扣1480. 一维数组的动态和
    Ribbon 和 Feign 的区别
    Eureka的自我保护机制
    Planar graph and map 3-colorability reduce to one another
    3-colorability
    一少年独坐屋中突然顿悟!-回溯
  • 原文地址:https://www.cnblogs.com/alibai/p/4027352.html
Copyright © 2011-2022 走看看