答案 0 :(得分:0)
您可以创建星期的选择一天额外的字段,然后就可以在isInvalidDate功能使用该字段的值。您也可以在parentEl财产和从外地此可以访问
指向共同的父元素
$(document).ready(function () {
$('#daterangepicker').daterangepicker({
parentEl: '.row',
isInvalidDate: function(date) {
return parseInt($(this.container).parent().find('select').val()) !== new Date(date).getDay();
}
});
});
<script type="text/javascript" src="https://cdn.jsdelivr.net/jquery/latest/jquery.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/momentjs/latest/moment.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/daterangepicker/daterangepicker.css" />
<div class="row">
<input id="daterangepicker" type="text" />
<select>
<option value="1">Mo</option>
<option value="2">Tu</option>
<option value="3">We</option>
<option value="4">Th</option>
<option value="5">Fr</option>
<option value="6">Sa</option>
<option value="0">Su</option>
</select>
</div>