[英]how to add time picker along with date picker
我在互聯網上搜索了很多,並嘗試了它們,但所有這些都無法正常工作,我的問題是如何顯示時間選擇器和日期選擇器
我已經有此代碼用於日期選擇器
<html> <head> <title>datetimepicker</title> <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.10.0.min.js" type="text/javascript"></script> <script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.10.2/jquery-ui.min.js" type="text/javascript"></script> <link href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.9.2/themes/blitzer/jqueryui.css"rel="Stylesheet" type="text/css" /> <script type="text/javascript" src="http://cdn.jsdelivr.net/json2/0.1/json2.js"></script> </head> <body> <input class="w3-input w3-border " type="text" id="txt_fupdate" size="25" title="Follow Up Date" placeholder="Follow Up Date " runat="server" required> <script type="text/javascript"> $(function () { $("#txt_fupdate").datepicker({ dateFormat: "dd-mm-yy" }).val() }); </script> </body> </html>
我的問題是我如何添加或更新該代碼以獲得時間選擇器,請對此提供幫助。
看看這個插件: http : //xdsoft.net/jqplugins/datetimepicker/
另外,我建議您可以在日期選擇器的右側添加一個額外的文本框,並將其與像這樣的時間選擇器綁定。
如前所述,您需要一個插件,請嘗試以下插件: https : //plugins.jquery.com/simple-dtpicker/
請記住在文件夾中包含必需的文件
jquery.simple-dtpicker.js和jquery.simple-dtpicker.css
您的代碼應該看起來像這樣:
<html>
<head>
<title>datetimepicker</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>
<script src="https://cdn.rawgit.com/mugifly/jquery-simple-datetimepicker/72933bbe/jquery.simple-dtpicker.js"></script>
<link href="https://cdn.rawgit.com/mugifly/jquery-simple-datetimepicker/72933bbe/jquery.simple-dtpicker.css" rel="stylesheet" />
</head>
<body>
<input id="txt_fupdate" class="w3-input w3-border " placeholder="Follow Up Date " required="" size="25" title="Follow Up Date" type="text" />
<script type="text/javascript">
$(function() {
$('#txt_fupdate').appendDtpicker({
"closeOnSelected": true
});
});
</script>
</body>
</html>
它簡單易行,並具有本地化等幾個良好功能。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.