【发布时间】:2018-10-08 20:01:40
【问题描述】:
我正在使用 jQuery datepicker 将日期作为参数附加到 url 的末尾。一切正常,但我想将日期格式化如下:
$('#datepicker').datepicker({inline: true, dateFormat: 'ddmmyy'});
当我在“onSelect”下方代码的第 7 行尝试这个时,'onSelect' 不起作用并且只是填充输入字段,我显然得到了语法或括号或什么错误?
<html lang="en">
<head>
<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"></scrip>
<script>
$(document).ready(function() {
$('#datepicker').datepicker({ <!-- The issue is here -->
onSelect : function (dateText, inst) {
var pathname = window.location.pathname;
var datepickedup = $("input#datepicker").val();
window.location.href = (pathname + "?startdate=" + datepickedup);
('#myform').submit();
}
});
});
</script>
</head>
<body>
<form id='myform' method="post">
<input type="text" id="datepicker"/>
</form>
</body>
</html>
【问题讨论】: