我遇到了Pikaday.js的问题,我可以“看看是什么问题。”
这是我的代码:
...
<link rel="stylesheet" href="css/styles.css">
<link rel="stylesheet" href="css/pikaday.css">
<script src="js/jquery-1.11.0.min.js"></script>
<script src="js/moment.min.js" type="text/javascript"></script>
<script src="js/pikaday.js" type="text/javascript"></script>
<script src="js/pikaday.jquery.js" type="text/javascript"></script>
<script>
var $datepicker = $('#datepicker').pikaday({
firstDay: 1,
minDate: new Date('2000-01-01'),
maxDate: new Date('2020-12-31'),
yearRange: [2000,2020]
});
</script>
....
<input type="text" id="datepicker">
答案 0 :(得分:2)
您可能需要等待页面完成加载并添加一段代码。
替换它:
var $datepicker = $('#datepicker').pikaday({
firstDay: 1,
minDate: new Date('2000-01-01'),
maxDate: new Date('2020-12-31'),
yearRange: [2000,2020]
});
有了这个:
jQuery(document).ready( function($){
var $datepicker = $('.datepicker').pikaday({
firstDay: 1,
minDate: new Date('2000-01-01'),
maxDate: new Date('2020-12-31'),
yearRange: [2000,2020]
});
$datepicker.pikaday('show');
});
并将其添加到输入class='datepicker'