为什么jqueryUI datepicker会抛出错误? [英] Why is jqueryUI datepicker throwing an error?
本文介绍了为什么jqueryUI datepicker会抛出错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试jqueryUI,但是firebug在这个脚本上捕获到以下错误:
I am trying out jqueryUI, but firebug catches the following error on this script:
$(function(){$("#date").datepicker()});
萤火虫错误如下:
$("#date").datepicker is not a function
在我的HTML上,日期ID如下所示:
On my html, the "date" id looks like this:
<input type="text" name="date" id="date" >
注意:我在
什么都没有执行......
Nothing is executing...
推荐答案
jQuery文档说你可以用这个命令调用datepicker:
jQuery documentation says you can call the datepicker by this command:
$("#datepicker").datepicker();
如果单击文档页面上的查看源按钮,您可以看到它们已经包装它进入 ready 函数:
If you click the 'view source' button on the documentation page you can see that they've wrapped it into the ready function:
$(document).ready(function(){
$("#datepicker").datepicker();
});
编辑:它应该与INPUT一起使用(感谢您指出Steerpike )。这是我编写的测试,它可以自行试用:
It should work with INPUT (thanks for pointing this out Steerpike). This is the test I've written and it works, try it yourself:
<html>
<head>
<link type="text/css" href="http://jqueryui.com/latest/themes/base/ui.all.css" rel="stylesheet" />
<script type="text/javascript" src="http://jqueryui.com/latest/jquery-1.3.2.js"></script>
<script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.core.js"></script>
<script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.datepicker.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#datepicker").datepicker();
});
</script>
</head>
<body>
<input type="text" id="datepicker" value="this is a test">
</body>
</html>
这篇关于为什么jqueryUI datepicker会抛出错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文