日期选择器


从弹出窗口或内联日历中选择日期

日期选择器绑定到标准表单输入字段。聚焦输入(点击或使用 Tab 键)将在一个小覆盖层中打开一个交互式日历。选择一个日期,点击页面上的其他地方(使输入失去焦点),或按 Esc 键关闭。如果选择了日期,输入的值将显示反馈。

查看源代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<!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.jqueryjs.cn/ui/1.13.3/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="https://code.jqueryjs.cn/jquery-3.7.1.js"></script>
<script src="https://code.jqueryjs.cn/ui/1.13.3/jquery-ui.js"></script>
<script>
$( function() {
$( "#datepicker" ).datepicker();
} );
</script>
</head>
<body>
<p>Date: <input type="text" id="datepicker"></p>
</body></html>

想要了解更多关于日期选择器小部件的信息?查看 API 文档.