jQuery datepicker格式根本不起作用

时间:2020-05-01 02:37:47

标签: jquery-ui

<!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网站的代码。

如您所见,这种格式根本不起作用!

您知道为什么它不起作用吗?

1 个答案:

答案 0 :(得分:1)

该属性不正确...应该是format而不是dateFormat

所以,而不是:

$( "#datepicker" ).datepicker({ format: 'yy-mm-dd' });

应该是:

$( "#datepicker" ).datepicker({ dateFormat: 'yy-mm-dd' });

API参考here

相关问题