国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

bootstrap daterangepicker漢化以及擴展功能

2019-11-19 16:19:52
字體:
來源:轉載
供稿:網友

bootstrap daterangepicker使用介紹,具體如下

一、擴展的功能

     1、初始化時,會自動創建一個select標簽;

     2、當改變select值時,日期也會自動改變,并且會調用apply按鈕的click事件

     3、點擊此處進行預覽

     4、github地址:https://github.com/lanleiming/daterangepicker-extend

二、效果展示

三、使用方法

1、替換掉原先的 daterangepicker.js 文件。
2、調用方法和原先一樣。 $('#config-demo').daterangepicker();

四、代碼實現

/* 擴展該組件:增加一個select */  var _this = this;  var selectItem = '<select id="dateranepicker_select" class="form-control width150 inline-block">';  selectItem += '<option>今日</option>';  selectItem += '<option>昨日</option>';  selectItem += '<option selected="selected">最近7日</option>';  selectItem += '<option>最近15日</option>';  selectItem += '<option>最近30日</option>';  selectItem += '<option>本月</option>';  selectItem += '<option>上月</option>';  selectItem += '</select>';  this.element.parent().append(selectItem);  $(document).on('change','#dateranepicker_select',function(){   function auto0(num){    return num>10?num:'0'+num;   }   var val = $(this).val();   var c_start_date = new Date();   var c_end_date = new Date();   if(val=='今日'){   }   else if(val=='昨日'){    c_start_date.setDate(c_start_date.getDate()-1);    c_end_date.setDate(c_end_date.getDate()-1);   }   else if(val=='最近7日'){    c_start_date.setDate(c_start_date.getDate()-7);    c_end_date.setDate(c_end_date.getDate()-1);   }   else if(val=='最近15日'){    c_start_date.setDate(c_start_date.getDate()-15);    c_end_date.setDate(c_end_date.getDate()-1);   }   else if(val=='最近30日'){    c_start_date.setDate(c_start_date.getDate()-30);    c_end_date.setDate(c_end_date.getDate()-1);   }   else if(val=='本月'){    var cyear = c_start_date.getFullYear();    var cmonth = c_start_date.getMonth();    c_start_date = new Date(cyear,cmonth,1);    c_end_date =new Date(cyear+'-'+ (cmonth+1) +'-'+new Date(cyear,cmonth+1,0).getDate());   }   else if(val=='上月'){    var cyear = c_start_date.getFullYear();    var cmonth = c_start_date.getMonth()-1;    c_start_date = new Date(cyear,cmonth,1);    c_end_date =new Date(cyear+'-'+ (cmonth+1) +'-'+new Date(cyear,cmonth+1,0).getDate());   }   _this.setStartDate(c_start_date);   _this.setEndDate(c_end_date);   timespanStr =auto0(c_start_date.getMonth()+1)+'/'+ auto0(c_start_date.getDate()) + '/'+c_start_date.getFullYear()+'-'+ auto0(c_end_date.getMonth()+1) + '/' +auto0(c_end_date.getDate()) + '/' +c_end_date.getFullYear();   _this.element.val(timespanStr);   _this.hide();   _this.element.trigger('apply.daterangepicker', _this);   /* 擴展該組件 end */  });

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林網。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 肥东县| 松滋市| 会理县| 嘉祥县| 宁武县| 建平县| 富蕴县| 南投县| 宁海县| 黄石市| 仁化县| 银川市| 呼玛县| 淮安市| 潮安县| 毕节市| 华宁县| 东山县| 蛟河市| 定兴县| 景宁| 德格县| 新兴县| 新民市| 新源县| 响水县| 绥江县| 泸州市| 桃园县| 呼和浩特市| 南陵县| 罗山县| 阜宁县| 台北市| 清丰县| 临桂县| 准格尔旗| 乌兰浩特市| 仁化县| 沭阳县| 博兴县|