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

问题描述 投票:0回答:1

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

enter image description here

我日历的javascript函数。

$('#datepicker').datepicker({
    changeYear: true,
    multidate: true,
    maxViewMode: 0,
    startDate: today,
})
javascript jquery bootstrap-datepicker
1个回答
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 !" />
© www.soinside.com 2019 - 2024. All rights reserved.