如何使用datepicker将默认日历格式更改为“dd / mm / yy”?以下代码无效。我在这里缺少什么?
html
答案 0 :(得分:0)
如果您使用jQuery DatePicker,则可以使用:
$(document).ready(function() {
$('.datepicker').datepicker({
dateFormat: 'dd/mm/yy'
});
});

<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<p>Date: <input type="text" class="datepicker"></p>
&#13;
如果您使用Bootstrap DatePicker,则需要:
$(".date").datepicker({
format: "dd/mm/yyyy"
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.9.0/moment-with-locales.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.7.1/js/bootstrap-datepicker.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.7.1/css/bootstrap-datepicker.css" rel="stylesheet"/>
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet"/>
<input type='text' class="form-control date" />
&#13;