如何为jquery的日期选择器创建状态管理/值/对象

e3bfsja2  于 2021-09-13  发布在  Java
关注(0)|答案(0)|浏览(129)

目标:
如果我选择了日期,例如2020年8月14日这两个日期选择器,然后我转到另一个网页。
稍后,我想用2个日期选择器返回此网页。这些日期选择器的上一个和所选日期在所选日期2020年8月14日仍然可用。您需要为这些日期选择器应用状态对象/值。
问题:
如何为这两个日期选择器应用状态管理/对象/值?
有可能这样做吗?我需要什么代码/插件才能实现目标:
jsfiddle:
https://jsfiddle.net/u7z9fmyd/3/
非常感谢。

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>SPLessons</title>
<link rel='stylesheet' type='text/css' href="http://code.jquery.com/ui/1.11.0/themes/smoothness/jquery-ui.css" type="text/css"> 
</head>

<body>

Start Date: <input class="questionDate" value=" 05/16/2015 "><br>
End Date: <input class="questionDate" value=" 05/31/2015 "><br>

<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.3.min.js"> </script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.11.1/jquery-ui.min.js"> </script>
<script type="text/javascript" src="script.js"> </script>

</body>
</html>
$(function() {
     $("input.questionDate").datepicker({
            dateFormat: 'mm/dd/yy'
        });

        $("input.questionDate").each(function(){
            var currentValue = $(this).val();
            if(currentValue)
                $(this).datepicker('setDate',new Date(currentValue));

        });
        $("input.questionDate").keydown(function(event) {
            if(event.keyCode != 8){
                event.preventDefault();
            }
        });

});

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题