jquery-ui - Jquery datepicker格式根本不起作用
问题描述
<!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 参考这里。
推荐阅读
- java - 在数据库的第一个添加新项目(位置 0)
- django - Django获取由外键标识的所有模型行
- azure - Windows 10 for Azure 上的 Windows Powershell 问题
- java - Spring websocket无法接收大数据
- html - Sticky header not working with resizable column in Primeng.?
- java - 如何关闭膨胀层?
- python - 错误 Python pandas:时间数据 '20160101-000000' 与格式 '%YYYY%mm%dd-%HH%MM%SS' 不匹配
- sql - 排除某些值的 SQL 约束?
- cloudkit - Cloudkit Dashboard - 添加测试用户
- jira - 如何在拆分为功能和页面时识别什么是史诗和故事?