2014-09-27 73 views
2
<!doctype html> 
<html lang="en"> 
<head> 

<meta charset="utf-8"> 
<meta content='width=device-width, initial-scale=1' name='viewport'/> 
    <title>jQuery UI Datepicker</title> 

    <link type="text/css" href="jquery-ui-1.8.16.custom/css/sunny/jquery-ui-1.8.16.custom.css" rel="stylesheet" /> 
    <script src="jquery-ui-1.8.16.custom/js/jquery-1.6.2.min.js"></script> 

    <script scrc="jquery-ui-1.8.16.custom/js/jquery-ui-1.8.16.custom.min.js"></script> 
</head> 
<body> 
    <h3>Date of Birth</h3> 
    <input type="text" name="birth_date" id="datepicker"> 
    <script> 
     $(document).ready(function(){ 
      $('#datepicker').datepicker(); 
     }); 
    </script> 
</body> 
</html> 

为什么这不起作用?尝试了几次,但在调试中得到相同的错误:Datepicker不起作用

对象不支持属性或方法'datepicker'。

+0

看来你没有包含datepicker.js和jquery-ui库。 – 2014-09-27 12:24:31

+0

我认为jquery.js和jquery-ui中存在版本控制问题。只要包含他们的最新版本。 – 2014-09-27 12:28:45

+0

你使用jQuery 1.6吗?如果是,那么我不确定它是否支持日期选择器。更新jQuery插件至少1.7.2,它将工作http://jsfiddle.net/dimomohit/2js1cykh/。希望这可以帮助你。 – DimoMohit 2014-09-27 12:31:58

回答

1

看起来你有一个错字这里

<script scrc="jquery-ui-1.8.16.custom/js/jquery-ui-1.8.16.custom.min.js"></script> 
---------^ 

任何错误scrc应更改为src

<script src="jquery-ui-1.8.16.custom/js/jquery-ui-1.8.16.custom.min.js"></script> 
+0

谢谢。这确实是一个错字。现在工作正常。 – ranjan 2014-09-27 12:54:37

0

试试这个小提琴Demo - here,在你的代码检查包括脚本正确加载,或者检查控制台显示

<link type="text/css" href="jquery-ui-1.8.16.custom/css/sunny/jquery-ui-1.8.16.custom.css" rel="stylesheet" /> 
    <script src="jquery-ui-1.8.16.custom/js/jquery-1.6.2.min.js"></script> 

    <script src="jquery-ui-1.8.16.custom/js/jquery-ui-1.8.16.custom.min.js"></script> 
</head>