2014-11-02 125 views
-1

我嘗試從jQuery UI使用datepicker,但它不工作,這是我的代碼。我應該添加什麼來使其工作?Datepicker jQuery UI不起作用

<html lang="us"> 
    <head> 
     <meta charset="utf-8"> 
     <title>jQuery UI Example Page</title> 
     <link href="jquery-ui.css" rel="stylesheet"> 

     <script src="external/jquery/jquery.js"></script> 
     <script src="jquery-ui.js"></script> 
     <script> 
      $(function() { 
       $("#datepicker").datepicker(); 
      }); 
     </script> 
    </head> 
    <body> 
     <p>Date: <input type="text" id="datepicker"></p> 
    </body> 
</html> 
+0

ID爲datepicker的元素在哪裏?請參閱此演示:http://jsfiddle.net/lotusgodkk/GCu2D/387/ – 2014-11-02 08:46:50

+0

「」和「」在哪裏? – Barmar 2014-11-02 08:47:16

+0

謝謝你的注意事項頭部和身體 – 2014-11-02 09:03:00

回答

0

您需要一個輸入欄,日期選取器可以存儲所選值。 在你的js的#datepicker定義了日期選擇器庫查找具有ID日期選擇一個元素(請參見下面的輸入字段):

<html lang="us"> 
<head> 
<meta charset="utf-8"> 
<title>jQuery UI Example Page</title> 
<link href="jquery-ui.css" rel="stylesheet"> 
<script src="external/jquery/jquery.js"></script> 
<script src="jquery-ui.js"></script> 
<script> 
    $(function() { 
     $("#datepicker").datepicker(); 
    }); 
</script> 
</head> 
<body> 

<p>Date: <input type="text" id="datepicker"></p> 

</body> 
</html> 

UPDATE

因爲你似乎有一些進一步的問題,這個版本適合你嗎?

<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.2/themes/smoothness/jquery-ui.css"> 
<script src="//code.jquery.com/jquery-1.10.2.js"></script> 
<script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script> 
<script> 
    $(function() { 
     $("#datepicker").datepicker(); 
    }); 
</script> 
</head> 
<body> 
<p>Date: <input type="text" id="datepicker"></p> 
</body> 
</html> 
+0

嗨,你是對的我錯過了文本,但我嘗試運行你的代碼,但它不工作也 – 2014-11-02 08:57:13

+0

你有正確的文件夾中的jQuery js? – 2014-11-02 08:59:27

+0

我已經添加了一個帶有js庫的外部鏈接的版本,請試試看。 – 2014-11-02 09:02:53