如何禁用日历中的月份点击

时间:2017-12-13 10:49:25

标签: javascript jquery bootstrap-datepicker

正如您在图像上看到的我要禁用2017年12月的点击(黑匣子)。我怎么能这样做?

enter image description here

我日历的javascript功能。

$('#datepicker').datepicker({
    changeYear: true,
    multidate: true,
    maxViewMode: 0,
    startDate: today,
})

1 个答案:

答案 0 :(得分:1)

也许您可以使用changeMonth选项,如下所示:



$('#datepicker').datepicker({
  changeYear: true,
  changeMonth: false,
  multidate: true,
  maxViewMode: 0,
  startDate: new Date(),
});

$('#datepicker2').datepicker({
  changeYear: true,
  changeMonth: true,
  multidate: true,
  maxViewMode: 0,
  startDate: new Date(),
});

input {
  width: 25%;
  margin: 1%;
}

<link href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>

<input type="text" id="datepicker" placeholder="You can't change my month !" />
<input type="text" id="datepicker2" placeholder="You can change my month !" />
&#13;
&#13;
&#13;