看起来像这个代码已经承诺不会在我的代码中工作。我想要做的是我有两个日期选择器。当我点击Date1时,我想禁用本月的所有日期。在选择日期2我想禁用date1的所有以前的日期。我无法理解我在这里错过了什么。请帮忙吗?禁用以前日期的多个日期选择器不起作用
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Datepicker - Default functionality</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$(function() {
$("#datepicker").datepicker();
$("#enddate").datepicker();
});
</script>
<script type="text/javascript">
$(document).ready(function() {
$("#datepicker").datepicker({
minDate: 0,
onSelect: function(date) {
$("#enddate").datepicker('option', 'minDate', date);
}
});
$("#enddate").datepicker({});
</script>
</head>
<body>
<p>Date1: <input type="text" id="datepicker"></p>
<p>Date2: <input type="text" id="enddate"></p>
</body>
</html>
您不能将一个'minDate'分配给还没有初始化的对象。 – Twisty
为什么你要初始化datepicker两次? – APECE