圆月山庄资源网 Design By www.vgjia.com
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 */ });
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
圆月山庄资源网 Design By www.vgjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
圆月山庄资源网 Design By www.vgjia.com
暂无评论...
更新日志
2024年09月30日
2024年09月30日
- 孙悦.1996-伙伴【正大国际】【WAV+CUE】
- 纪钧瀚《钢琴阅读时光 雨中书店聆听轻音乐》[FLAC/分轨][399.62MB]
- 证声音乐图书馆《走向自然 疗心爵士乐》[320K/MP3][87.4MB]
- 证声音乐图书馆《走向自然 疗心爵士乐》[FLAC/分轨][184.94MB]
- 陈慧娴.2018-Priscilla-Ism演唱会3CD(2024环球红馆40复刻系列)【环球】【WAV+CUE】
- 郑秀文.1999-我应该得到(国)【华纳】【WAV+CUE】
- 陈家慧.2011-钢琴酒吧2CD【龙吟唱片】【WAV+CUE】
- 证声音乐图书馆《雨季 蓝调吉他 Rainy Blues》[320K/MP3][45.01MB]
- 证声音乐图书馆《雨季 蓝调吉他 Rainy Blues》[FLAC/分轨][109.13MB]
- 赞多《序章》[320K/MP3][45.54MB]
- 许巍.2004-每一刻都是崭新的【步升大风】【WAV+CUE】
- 群星.2024-四方馆影视原声带【韶愔音乐】【FLAC分轨】
- 陈雷.1997-安锁咧【金圆唱片】【WAV+CUE】
- 关淑怡.2013-MY.FAVORITE.SK.3CD【环球】【WAV+CUE】
- Sweety.2006-花言乔语【丰华】【WAV+CUE】