日期选取器 UI 在编辑页面上无法正常工作



我使用日期选择器UI来选择开始日期和结束日期。它在创建页面上正常工作。但在编辑页面上无法正常工作。当我在编辑页面中单击开始日期时,结束日期自动变为空。我使用以下JavaScript。CSS 和 JS 文件:

<link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/cupertino/jquery-ui.css">
        <script src="//code.jquery.com/jquery-1.10.2.js"></script>
        <script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>

Javascript:

$(document).ready(function () {
    $("#from").datepicker({
        dateFormat: 'dd/mm/yy',
        changeMonth: true,
        changeYear: true,
        numberOfMonths: 1,
        onClose: function (selectedDate) {
            $("#to").datepicker("option", "minDate", selectedDate);
        }
    });
    $("#to").datepicker({
        dateFormat: 'dd/mm/yy',
        changeMonth: true,
        changeYear: true,
        numberOfMonths: 1,
        onClose: function (selectedDate) {
            $("#from").datepicker("option", "maxDate", selectedDate);
        }
    });
});

我的观点:

<p>Start Date: <input type="text" id="from"></p>
<p>End Date: <input type="text" id="to"></p>

查看错误屏幕截图:https://i.stack.imgur.com/wwtiH.png当我单击开始日期时,它默认突出显示并仅显示当前日期。

https://i.stack.imgur.com/wwtiH.png选择"开始日期"后,"结束日期"自动变为空。并且还默认显示2020年。

importjquery-1.10.2.jsjquery-ui.jsjquery-ui.css您的代码将开始运行

最新更新