看起來像這個代碼已經承諾不會在我的代碼中工作。我想要做的是我有兩個日期選擇器。當我點擊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