Bootstrap3 datetimepicker控件使用實(shí)例
Bootstrap3 日期+時(shí)間選擇控件的使用方法,供大家參考,具體內(nèi)容如下
1.支持日期選擇,格式設(shè)定
2.支持時(shí)間選擇
3.支持時(shí)間段選擇控制
4.支持中文
官網(wǎng)地址:http://eonasdan.github.io/bootstrap-datetimepicker/
git地址:https://github.com/Eonasdan/bootstrap-datetimepicker
moment語言包:https://github.com/moment/moment
datetimepicker使用配置說明:http://eonasdan.github.io/bootstrap-datetimepicker/Options/
moment時(shí)間格式化使用說明:http://momentjs.com/docs/
使用方法,引用的文件:
<script src="../Js/jquery-1.11.3.min.js"></script> <link href="../Js/bootstrap-3.3.5-dist/css/bootstrap.css" rel="stylesheet" /> <script src="../Js/bootstrap-3.3.5-dist/js/bootstrap.min.js"></script> <link href="../Js/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css" rel="stylesheet" /> <script src="../Js/bootstrap-datetimepicker/js/moment-with-locales.min.js"></script> <script src="../Js/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
實(shí)例1,簡(jiǎn)單配置:
<div class="row"> <div class='col-sm-6'> <div class="form-group"> <label>選擇日期:</label> <!--指定 date標(biāo)記--> <div class='input-group date' id='datetimepicker1'> <input type='text' class="form-control" /> <span class="input-group-addon"> <span class="glyphicon glyphicon-calendar"></span> </span> </div> </div> </div> <div class='col-sm-6'> <div class="form-group"> <label>選擇日期+時(shí)間:</label> <!--指定 date標(biāo)記--> <div class='input-group date' id='datetimepicker2'> <input type='text' class="form-control" /> <span class="input-group-addon"> <span class="glyphicon glyphicon-calendar"></span> </span> </div> </div> </div> </div>
$(function () {
$('#datetimepicker1').datetimepicker({ format: 'YYYY-MM-DD', locale: moment.locale('zh-cn') }); $('#datetimepicker2').datetimepicker({ format: 'YYYY-MM-DD hh:mm', locale: moment.locale('zh-cn') }); });
實(shí)例2,選擇時(shí)間段:
<div class="row"> <div class='col-sm-6'> <div class="form-group"> <label>選擇開始時(shí)間:</label> <!--指定 date標(biāo)記--> <div class='input-group date' id='datetimepicker1'> <input type='text' class="form-control" /> <span class="input-group-addon"> <span class="glyphicon glyphicon-calendar"></span> </span> </div> </div> </div> <div class='col-sm-6'> <div class="form-group"> <label>選擇結(jié)束時(shí)間:</label> <!--指定 date標(biāo)記--> <div class='input-group date' id='datetimepicker2'> <input type='text' class="form-control" /> <span class="input-group-addon"> <span class="glyphicon glyphicon-calendar"></span> </span> </div> </div> </div> </div>
$(function () { var picker1 = $('#datetimepicker1').datetimepicker({ format: 'YYYY-MM-DD', locale: moment.locale('zh-cn'), //minDate: '2016-7-1' }); var picker2 = $('#datetimepicker2').datetimepicker({ format: 'YYYY-MM-DD', locale: moment.locale('zh-cn') }); //動(dòng)態(tài)設(shè)置最小值 picker1.on('dp.change', function (e) { picker2.data('DateTimePicker').minDate(e.date); }); //動(dòng)態(tài)設(shè)置最大值 picker2.on('dp.change', function (e) { picker1.data('DateTimePicker').maxDate(e.date); }); });
如果大家還想深入學(xué)習(xí),可以點(diǎn)擊這里進(jìn)行學(xué)習(xí),再為大家附3個(gè)精彩的專題:
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- Bootstrap時(shí)間選擇器datetimepicker和daterangepicker使用實(shí)例解析
- angularjs封裝bootstrap時(shí)間插件datetimepicker
- bootstrap datetimepicker日期插件超詳細(xì)使用方法介紹
- bootstrap datetimepicker日期插件使用方法
- bootstrap-datetimepicker實(shí)現(xiàn)只顯示到日期的方法
- Bootstrap 設(shè)置datetimepicker在屏幕上面彈出設(shè)置方法
- bootstrap datetimepicker實(shí)現(xiàn)秒鐘選擇下拉框
- vue2.0 與 bootstrap datetimepicker的結(jié)合使用實(shí)例
- 基于bootstrap-datetimepicker.js不支持IE8的快速解決方法
- bootstrap datetimepicker控件位置異常的解決方法
相關(guān)文章
實(shí)例詳解JSON數(shù)據(jù)格式及json格式數(shù)據(jù)域字符串相互轉(zhuǎn)換
JSON(JavaScript Object Notation)是一種輕量級(jí)的數(shù)據(jù)交換格式。JSON采用完全獨(dú)立于語言的文本格式,這些特性使JSON成為理想的數(shù)據(jù)交換語言2016-01-01Webpack 之 babel-loader文件預(yù)處理器詳解
這篇文章主要介紹了Webpack 之 babel-loader文件預(yù)處理器詳解,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2018-03-03JS中不為人知的五種聲明Number的方式簡(jiǎn)要概述
聲明一個(gè)數(shù)值類型的變量我看到三種;我嘴角微微一笑:少年你還嫩了點(diǎn),哪止三種,我知道的至少有五種,好奇的你可以參考下哈,希望本文可以幫助到你2013-02-02微信小程序骨架屏的應(yīng)用與實(shí)現(xiàn)步驟詳細(xì)記錄
所謂骨架屏就是在頁(yè)面數(shù)據(jù)尚未加載前先給用戶展示出頁(yè)面的大致結(jié)構(gòu),直到請(qǐng)求數(shù)據(jù)返回后再渲染頁(yè)面,補(bǔ)充進(jìn)需要顯示的數(shù)據(jù)內(nèi)容,這篇文章主要給大家介紹了關(guān)于微信小程序骨架屏的應(yīng)用與實(shí)現(xiàn)的相關(guān)資料,需要的朋友可以參考下2022-05-05js取兩個(gè)數(shù)組的交集|差集|并集|補(bǔ)集|去重示例代碼
求兩個(gè)集合的補(bǔ)集、交集、差集、并集等等在實(shí)際應(yīng)用中經(jīng)常會(huì)使用到,下面與大家分享下具體的實(shí)現(xiàn)代碼,感興趣的朋友可以參考下,希望對(duì)大家有所幫助2013-08-08JS表單驗(yàn)證插件之?dāng)?shù)據(jù)與邏輯分離操作實(shí)例分析【策略模式】
這篇文章主要介紹了JS表單驗(yàn)證插件之?dāng)?shù)據(jù)與邏輯分離操作,結(jié)合實(shí)例形式分析了JavaScript基于策略模式實(shí)現(xiàn)數(shù)據(jù)與邏輯分離的表單驗(yàn)證插件相關(guān)原理、操作技巧及注意事項(xiàng),需要的朋友可以參考下2020-05-05前端HTTP發(fā)POST請(qǐng)求攜帶參數(shù)與后端接口接收參數(shù)的實(shí)現(xiàn)
近期在學(xué)習(xí)的時(shí)候,碰到一個(gè)關(guān)于post的小問題,故拿出來分享一下,下面這篇文章主要給大家介紹了關(guān)于前端HTTP發(fā)POST請(qǐng)求攜帶參數(shù)與后端接口接收參數(shù)的相關(guān)資料,需要的朋友可以參考下2022-10-10javascript 用記憶函數(shù)快速計(jì)算遞歸函數(shù)
摘自《JavaScript: The Good Parts》,作為讀書筆記備用。對(duì)于追求執(zhí)行效率的朋友可以參考下。2010-03-03