1、获取 url 地址的参数

function GetQueryString(name) {

  var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");

       var r = window.location.search.substr(1).match(reg);

        if (r != null) {

              return decodeURI(r[2]);

         } else {

               return null;

          }

}

2、checkbox 最多只能选几项  

    if (this.checked && elem.filter(':checked').length > maxLength) this.checked = false

3、时间日期格式转化 

function isZero(m){
  return m<10?'0'+m:m
}
function formatNewDate(timeSrt,type=true) {
  var timeReg = timeSrt.replace(/\./g, '/')
  //timeReg = timeSrt.replace(/\-/g, '/')
  var time = new Date(timeReg);
  var y = time.getFullYear();
  var m = time.getMonth()+1;
  var d = time.getDate();
  var h = time.getHours();
  var mm = time.getMinutes();
  var s = time.getSeconds();
  //return y+'/'+isZero(m)+'/'+isZero(d)+' '+isZero(h)+':'+isZero(mm)+':'+isZero(s);
  if(type){
    return isZero(m)+'/'+ isZero(d)+' '+isZero(h)+':'+isZero(mm)
  }else{
    return isZero(m)+'月'+ isZero(d)+'日'
  }
}

 

相关文章:

  • 2021-07-29
  • 2022-12-23
  • 2022-01-10
  • 2022-12-23
  • 2021-10-08
猜你喜欢
  • 2021-10-14
  • 2022-12-23
  • 2021-07-20
  • 2022-03-07
  • 2021-12-28
  • 2022-02-04
相关资源
相似解决方案