gpt4 book ai didi

javascript - Bootstrap datepicker setDatesDisabled 在按钮单击时不起作用

转载 作者:行者123 更新时间:2023-11-28 15:11:16 32 4
gpt4 key购买 nike

尝试在 Bootstrap 日期选择器的按钮单击时 setDatesDisabled,但它不起作用。

HTML:

<div id="container">
<div id="date-range">
<div class="range-start"></div>
<div class="range-end"></div>
</div>
<button id="button" class="btn btn-warning">Disable Dates</button>
</div>

JavaScript:

$(function() {
$('#date-range').datepicker({
inputs: $('.range-start, .range-end'),
format: 'yyyy-mm-dd',
datesDisabled: ['2016-04-21', '2016-04-20', '2016-04-13']
});

$('#button').click(function() {
$('#date-range').datepicker('setDatesDisabled', ['2016-04-29', '2016-04-30']);
});
});

fiddle :https://jsfiddle.net/kaygee79/953zk742/

最佳答案

使用初始化日期选择器时指定的输入

$(function() {
$('#date-range').datepicker({
inputs: $('.range-start, .range-end'),
format: 'yyyy-mm-dd',
datesDisabled: ['2016-04-21', '2016-04-20', '2016-04-13']
});

$('#button').click(function() {
$('.range-start').datepicker('setDatesDisabled', ['2016-04-29', '2016-04-30']);
$('.range-end').datepicker('setDatesDisabled', ['2016-04-29', '2016-04-30']);
});
});

工作 fiddle : https://jsfiddle.net/f50ga49j/

关于javascript - Bootstrap datepicker setDatesDisabled 在按钮单击时不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36361975/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com