![](/img/trans.png)
[英]eonasdan bootstrap-datetimepicker 4 show years on reopen
[英]Eonasdan/bootstrap-datetimepicker option on a custom script
我需要在我的日期選擇器字段中添加一些選項,遵循文檔說明,但是我需要處理自定義腳本,並且需要使用javascript的一些幫助。
這是我的腳本
HTML:
<div class="form-group col-md-6">
<label for="name">StartDate</label>
<input type="date" class="form-control" name="startdate" placeholder="Start Date" value="04/03/2018">
</div>
JavaScript的:
$('.form-group input[type=date]').each(function (idx, elt) {
if (elt.type != 'date' || elt.hasAttribute('data-datepicker')) {
elt.type = 'text';
$(elt).datetimepicker($(elt).data('datepicker'));
}
});
我嘗試添加:
$(elt).datetimepicker({
locale: 'it',
format: 'DD/MM/YYYY'
});
設置格式和語言環境,但不起作用。
這是小提琴: https : //jsfiddle.net/iotivedo/qf5eopdr/6/
您嘗試在哪里閱讀文檔?
似乎您沒有遵循Bootstrap 3 Datepicker v4 Docs
參見https://eonasdan.github.io/bootstrap-datetimepicker/
你可以試試:
(HTML)
<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>
(JS)
$('#datetimepicker1').datetimepicker({
format: 'DD/MM/YYYY',
locate: 'it'
});
配置顯示格式並找到。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.