zoukankan      html  css  js  c++  java
  • jQuery radio的取值与赋值

    HTML

    <div class="weui-cell">
                <div class="weui-cell__hd"><label class="weui-label">性别</label></div>
                <div class="weui-cell__bd">
                    <input class="weui-radio" name="sex" type="radio" value="1" style=" 18px;height: 18px;vertical-align: text-bottom;margin-bottom: 2px;"><input class="weui-radio" name="sex" type="radio" value="2" style=" 18px;height: 18px;vertical-align: text-bottom;margin-bottom: 2px;margin-left: 12px"><!--<input type="radio" class="radio-la" name="n" id="check-1" hidden="">
                    <input type="radio" class="radio-la" name="n" id="check-2" hidden="">-->
                </div>
            </div>

    取值:

    let identity = $('input:radio[name=identity]:checked').val();
        let sex = $('input:radio[name=sex]:checked').val();

    回显:

    let identity = obj.identity;
                    let sex = obj.sex;
                    $(":radio[name='identity'][value='" + identity + "']").prop("checked", "checked");
                    $(":radio[name='sex'][value='" + sex + "']").prop("checked", "checked");
  • 相关阅读:
    Java语言
    Java面向对象编程思想
    final关键字
    abstract关键字
    对象初始化过程
    访问修饰符
    继承
    面向对象设计
    static
    封装
  • 原文地址:https://www.cnblogs.com/zxyun/p/9330533.html
Copyright © 2011-2022 走看看