我正在尝试实现 bootstrap-datepicker.js 插件。 ( https://bootstrap-datepicker.readthedocs.io/en/latest/ ) 我有 .js 和 .css 文件,但我得到了这个难看的中文标准 jquery datepicker:
$('#test').datepicker({ });
我该如何解决这个问题?
我的代码:
<input type="text" id="test" name="test" class="sm-form-control" placeholder="DD-MM-JJJJ" autocomplete="off">
$(document).ready(function () {
$('#test').datepicker({
onSelect: function(d,i){
if(d !== i.lastVal){
$(this).change();
}
}
});
$('#test').change(function(){
console.log('Test');
});
});
谢谢, 迈克
最佳答案
JQueryUI
和Bootstrap
之间存在冲突,用于datepicker
检查Check this link
$.fn.datepicker.noConflict = function(){
$.fn.datepicker = old;
return this;
};
或者你可以使用JQuery-UI
$( function() {
$( "#test" ).datepicker({
language: 'zh-TW'
});
});
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Datepicker - Default functionality</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.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>
<script src="i18n/datepicker-zh-TW.js"></script>
<body>
<p>Date:<input type="text" id="test" name="test" class="sm-form-control" placeholder="DD-MM-JJJJ" autocomplete="off">
</body>
关于javascript - 丑陋的引导日期选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52496789/