[英]JQuery UI date picker working in jsbin but not locally
我正在使用sublime text 3,並且已經測試了其他jQuery UI元素,但是決定今天嘗試將日期選擇器與我正在整理的一個小項目一起使用。 我注意到,當我想嘗試一下時,我首先將示例的默認代碼保存在jQuery網站上的本地.html文件中,然后嘗試加載它。
示例中的默認代碼:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Datepicker - Default functionality</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<script>
$(function() {
$("#datepicker").datepicker();
});
</script>
</head>
<body>
<p>Date:
<input type="text" id="datepicker">
</p>
</body>
</html>
不幸的是,這會彈出一個輸入字段,但是在單擊該字段時,我無法選擇日期。 實際上,日期選擇下拉列表根本沒有顯示,但我可以確定輸入字段已被選擇。 我以為在將代碼復制到測試文件時可能遺漏了一些東西,所以我加載了JSBin並將代碼粘貼到那里。 神奇地,它有效。 在JSBin示例中,我假設我以某種方式未鏈接到jQuery UI的適當樣式表或CDN。 這個假設是正確的還是為什么它在本地不起作用?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Datepicker - Default functionality</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script>
$(function() {
$( "#datepicker" ).datepicker();
});
</script>
</head>
<body>
<p>Date: <input type="text" id="datepicker"></p>
</body>
</html>
PS-我已經刪除了指向CSS文件的鏈接,因為它可能是您本地的CSS文件。 您可以添加回去。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.