zoukankan      html  css  js  c++  java
  • 转(时间对象的格式化&javascript应用:实现复选框全选/全不选切换)

    <script language="JavaScript">
    Date.prototype.format = function(format)
    {
      var o = {
        "M+" : this.getMonth()+1, //month
        "d+" : this.getDate(),    //day
        "h+" : this.getHours(),   //hour
        "m+" : this.getMinutes(), //minute
        "s+" : this.getSeconds(), //second
        "q+" : Math.floor((this.getMonth()+3)/3),  //quarter
        "S" : this.getMilliseconds() //millisecond
      }
      if(/(y+)/.test(format)) format=format.replace(RegExp.$1,
        (this.getFullYear()+"").substr(4 - RegExp.$1.length));
      for(var k in o)if(new RegExp("("+ k +")").test(format))
        format = format.replace(RegExp.$1,
          RegExp.$1.length==1 ? o[k] :
            ("00"+ o[k]).substr((""+ o[k]).length));
      return format;
    }
    alert(new Date().format("yyyy-MM-dd hh:mm:ss"));
    </script>



    input type=checkbox name=mm value=a onclick="checkItem(this, 'mmAll')"><br>
    <input type=checkbox name=mm value=b onclick="checkItem(this, 'mmAll')"><br>
    <input type=checkbox name=mm value=c onclick="checkItem(this, 'mmAll')"><br>
    <input type=checkbox name=mm value=d onclick="checkItem(this, 'mmAll')"><br>
    <input type=checkbox name=mm value=e onclick="checkItem(this, 'mmAll')"><br><br>
    <input type=checkbox name=mmAll onclick="checkAll(this, 'mm')">全选与不全选的切换

    <script language=Javascript>
    function checkAll(e, itemName)
    {
      var aa = document.getElementsByName(itemName);
      for (var i=0; i<aa.length; i++)
       aa[i].checked = e.checked;
    }
    function checkItem(e, allName)
    {
      var all = document.getElementsByName(allName)[0];
      if(!e.checked) all.checked = false;
      else
      {
        var aa = document.getElementsByName(e.name);
        for (var i=0; i<aa.length; i++)
         if(!aa[i].checked) return;
        all.checked = true;
      }
    }
    </script>


  • 相关阅读:
    springboot + mybatis-pagehelper 参数查询不分页的bug。。。
    不错位的java .class 反编译工具推荐
    git 生成ssh keys
    Spring boot 通用配置文件模板
    Shiro系列(3)
    Shiro系列(2)
    Shiro系列(1)
    updating
    前端速查手册——Note
    Java进阶知识与技术
  • 原文地址:https://www.cnblogs.com/zwei1121/p/900303.html
Copyright © 2011-2022 走看看