Datepicker jQuery UI不起作用

问题描述:

我尝试从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

您需要一个输入栏,日期选取器可以存储所选值。 在你的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