<!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="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="https://code.jquery.com/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({ format: 'yy-mm-dd' });
} );
</script>
</head>
<body>
<p>Date: <input type="text" id="datepicker"></p>
</body>
</html>
这是jquery UI网站的代码。
就像你看到的那样,这种格式根本就不能用!你知道为什么不能用吗?
你知道为什么它不工作吗?
属性是不正确的......而非 format
应是 dateFormat
:
因此,将其改为:
$( "#datepicker" ).datepicker({ format: 'yy-mm-dd' });
应该是:
$( "#datepicker" ).datepicker({ dateFormat: 'yy-mm-dd' });
API参考文献 此处.