jQuery Mobile - Datapicker 日期选择器小工具
描述
DatePicker 函数可以与使用 jQuery Mobile 中的 JqueryUI 的小部件一起使用,因为它不支持 jQuery Mobile 小部件。 它用于专注于输入以在小覆盖层中打开交互式日历。
弹出式日期选择器
当输入聚焦于插入日期时,日历会弹出。 在 <input> 字段中添加 data-role = "date" 属性以包含日期,它以 dd/mm/yy 格式显示。
示例
以下示例演示了在 jQuery Mobile 中使用 弹出日期选择器。
<!DOCTYPE html>
<html>
<head>
<meta name = "viewport" content = "width = device-width, initial-scale = 1">
<link rel = "stylesheet" href = "https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
<link rel = "stylesheet" href = "https://rawgithub.com/arschmitz/jquery-mobile-datepicker-wrapper/master/jquery.mobile.datepicker.css" />
<script src = "https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src = "https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
<script src = "https://rawgithub.com/jquery/jquery-ui/1-10-stable/ui/jquery.ui.datepicker.js"></script>
<script src = "https://rawgithub.com/arschmitz/jquery-mobile-datepicker-wrapper/master/jquery.mobile.datepicker.js"></script>
</head>
<body>
<h2>Popup Datapicker Example</h2>
<form>
<input type = "text" data-role = "date">
</form>
</body>
</html>
输出
让我们执行以下步骤,看看上面的代码是如何工作的 −
将上述 html 代码保存为服务器根文件夹中的 popup_datapicker.html 文件。
将此 HTML 文件打开为 http://localhost/popup_datapicker.html,将显示以下输出。
内联日期选择器。
包括 data-inline = "true" 以显示交互式日历。
示例
以下示例演示了在 jQuery Mobile 中使用内联日期选择器。
<!DOCTYPE html>
<html>
<head>
<meta name = "viewport" content = "width = device-width, initial-scale = 1">
<link rel = "stylesheet" href = "https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
<link rel = "stylesheet" href = "https://rawgithub.com/arschmitz/jquery-mobile-datepicker-wrapper/master/jquery.mobile.datepicker.css" />
<script src = "https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src = "https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
<script src = "https://rawgithub.com/jquery/jquery-ui/1-10-stable/ui/jquery.ui.datepicker.js"></script>
<script src = "https://rawgithub.com/arschmitz/jquery-mobile-datepicker-wrapper/master/jquery.mobile.datepicker.js"></script>
</head>
<body>
<h2>Popup Datapicker Example</h2>
<form>
<input type = "text" data-role = "date" data-inline = "true">
</form>
</body>
</html>
输出
让我们执行以下步骤,看看上面的代码是如何工作的 −
将上述 html 代码保存为服务器根文件夹中的 inline_datapicker.html 文件。
将此 HTML 文件打开为 http://localhost/inline_datapicker.html,将显示以下输出。

