zoukankan      html  css  js  c++  java
  • 复选框checkbox

    复选框:checkbox
    html 结构 <input type="checkbox" value="test" />测试

    获取value值
            function getValue() {
                var str = "";
                for (var i = 0; i < list.length; i++) {
                    var tmp = list[i];
                    if (tmp.type == "checkbox") {   // 判断类型
                        if (tmp.checked) {          // 判断是否选中
                            str += tmp.value;
                        }
                    }
                }
                alert(str);
            }

    全选
            function checkAll() {
                for (var i = 0; i < list.length; i++) {
                    var tmp = list[i];
                    if (tmp.type == "checkbox") {
                        if (!tmp.checked) {
                            tmp.checked = true;
                        }
                    }
                }
            }
    取消全选
            function removeAll() {
                for (var i = 0; i < list.length; i++) {
                    var tmp = list[i];
                    if (tmp.type == "checkbox") {
                        if (tmp.checked) {
                            tmp.checked = false;
                        }
                    }
                }
            }
    反选
            function antiAll() {
                for (var i = 0; i < list.length; i++) {
                    var tmp = list[i];
                    if (tmp.type == "checkbox") {
                        if (tmp.checked) {
                            tmp.checked = false;
                        }
                        else {
                            tmp.checked = true;
                        }
                    }
                }
            }

  • 相关阅读:
    方法的调用机制
    类的成员之二:方法
    类的成员之一:属性
    关键字static
    构造器
    this关键字
    递归方法(recursion)
    方法重载(二)
    GTID 跳过脚本
    mydumper 找不到libmysqlclient.so.20
  • 原文地址:https://www.cnblogs.com/kuikui/p/2341765.html
Copyright © 2011-2022 走看看