bootstrap4日期时间选择器插件
源码介绍
这是一款bootstrap4日期时间选择器插件。该bootstrap4日期时间选择器插件提供大量配置参数,可以基于bootstrap4制作出简单实用的日期选择器效果。它的特点还有:
在页面中引入jquery和bootstrap4相关文件,以及moment.js和tempusdominus-bootstrap-4.min.js文件。 一个最基本的bootstrap4日期时间选择器的HTML结构如下。 在页面DOM元素加载完毕之后,通过 该bootstrap4日期选择器插件的可用配置参数有: 该bootstrap4日期选择器插件的github地址为:https://github.com/tempusdominus/bootstrap-4简要教程
使用方法
<link href="css/bootstrap.min.css" rel="stylesheet">
<script src="jquery.min.js"></script>
<script src="bootstrap.min.js"></script>
<script src="moment.js"></script>
<script src="tempusdominus-bootstrap-4.min.js"></script>
HTML结构
<div class="container">
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<div class="input-group date" id="datetimepicker1" data-target-input="nearest">
<input type="text" class="form-control datetimepicker-input" data-target="#datetimepicker1"/>
<div class="input-group-append" data-target="#datetimepicker1" data-toggle="datetimepicker">
<div class="input-group-text"><i class="fa fa-calendar"></i></div>
</div>
</div>
</div>
</div>
</div>
</div>
初始化插件
datetimepicker
方法来初始化该bootstrap4日期选择器插件。
<script type="text/javascript">
$(function () {
$('#datetimepicker1').datetimepicker();
});
</script>
配置参数
$('#datetimepicker-demo').datetimepicker({
// requires moment-timezone.js
timeZone: '',
// date format
// http://momentjs.com/docs/#/displaying/format/
format: false,
dayViewHeaderFormat: 'MMMM YYYY',
extraFormats: false,
// step size
stepping: 1,
// min/max dates
minDate: false,
maxDate: false,
// uses current date/time
useCurrent: true,
// uses Bootstraps collapse to switch between date/time pickers
collapse: true,
// https://github.com/moment/moment/tree/develop/locale
locale: moment.locale(),
// default date
defaultDate: false,
// disabled dates
// array of [date, moment, string]
disabledDates: false,
// enabled dates
// array of [date, moment, string]
enabledDates: false,
// default icons
icons: {
time: 'fa fa-clock-o',
date: 'fa fa-calendar',
up: 'fa fa-arrow-up',
down: 'fa fa-arrow-down',
previous: 'fa fa-chevron-left',
next: 'fa fa-chevron-right',
today: 'fa fa-calendar-check-o',
clear: 'fa fa-delete',
close: 'fa fa-times'
},
// tooltip options
tooltips: {
today: 'Go to today',
clear: 'Clear selection',
close: 'Close the picker',
selectMonth: 'Select Month',
prevMonth: 'Previous Month',
nextMonth: 'Next Month',
selectYear: 'Select Year',
prevYear: 'Previous Year',
nextYear: 'Next Year',
selectDecade: 'Select Decade',
prevDecade: 'Previous Decade',
nextDecade: 'Next Decade',
prevCentury: 'Previous Century',
nextCentury: 'Next Century',
pickHour: 'Pick Hour',
incrementHour: 'Increment Hour',
decrementHour: 'Decrement Hour',
pickMinute: 'Pick Minute',
incrementMinute: 'Increment Minute',
decrementMinute: 'Decrement Minute',
pickSecond: 'Pick Second',
incrementSecond: 'Increment Second',
decrementSecond: 'Decrement Second',
togglePeriod: 'Toggle Period',
selectTime: 'Select Time',
selectDate: 'Select Date'
},
// uses strict
useStrict: false,
// displays side by side
sideBySide: false,
// disabled days of the week
daysOfWeekDisabled: false,
// shows the week of the year
calendarWeeks: false,
// 'decades','years','months','days'
viewMode: 'days',
// toolbar placement
toolbarPlacement: 'default',
// enable/disable buttons
buttons: {
showToday: false,
showClear: false,
showClose: false
},
// widget position
widgetPositioning: {
horizontal: 'auto',
vertical: 'auto'
},
// string or jQuery object
widgetParent: null,
// ignore read only input
ignoreReadonly: false,
// always keep open
keepOpen: false,
// shows on focus
focusOnShow: true,
// inline mode
inline: false,
// makes the date picker not revert or overwrite invalid dates
keepInvalid: false,
// debug mode
debug: false,
// shows on focus and icon click
allowInputToggle: false,
// disables time selection
disabledTimeIntervals: false,
// disables/enables hours
disabledHours: false,
enabledHours: false,
// changes the viewDate without changing or setting the selected date
viewDate: false,
// allows multiple dates
allowMultidate: false,
// custom separator
multidateSeparator: ','
});
本站资源均来自互联网,仅供研究学习,禁止违法使用和商用,产生法律纠纷本站概不负责!如果侵犯了您的权益请与我们联系!
转载请注明出处: 免费源码网-免费的源码资源网站 » bootstrap4日期时间选择器插件
发表评论 取消回复