最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Why is jqueryUI datepicker throwing an error? - Stack Overflow

programmeradmin2浏览0评论

I am trying out jqueryUI, but firebug catches the following error on this script:

$(function(){$("#date").datepicker()});

The firebug error reads:

$("#date").datepicker is not a function

On my html, the "date" id looks like this:

<input type="text" name="date" id="date" >

NB: I have used the correct JqueryUI css/js scripts on the section

Nothing is executing...

I am trying out jqueryUI, but firebug catches the following error on this script:

$(function(){$("#date").datepicker()});

The firebug error reads:

$("#date").datepicker is not a function

On my html, the "date" id looks like this:

<input type="text" name="date" id="date" >

NB: I have used the correct JqueryUI css/js scripts on the section

Nothing is executing...

Share Improve this question edited Jul 30, 2012 at 2:10 WEFX 8,5628 gold badges69 silver badges104 bronze badges asked Apr 3, 2009 at 9:28 GathGath 1,3454 gold badges15 silver badges14 bronze badges
Add a ment  | 

6 Answers 6

Reset to default 3

jQuery documentation says you can call the datepicker by this mand:

$("#datepicker").datepicker();

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();
  });

EDIT: 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./latest/themes/base/ui.all.css" rel="stylesheet" />
  <script type="text/javascript" src="http://jqueryui./latest/jquery-1.3.2.js"></script>
  <script type="text/javascript" src="http://jqueryui./latest/ui/ui.core.js"></script>
  <script type="text/javascript" src="http://jqueryui./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>

You're almost certainly not loading the datepicker plugin properly. Please supply us the code you're using to include the javascript files.

If you keep having problems, load the jquery and the UI from the google api.

<link type="text/css" href="http://jqueryui./latest/themes/base/ui.all.css" rel="stylesheet" />

<script type="text/javascript" src="http://www.google./jsapi"></script>
<script type="text/javascript">
    google.load("jquery", "1.3.2");
    google.load("jqueryui", "1.7.0");
</script>

for me it was just case of making sure the jquery ui was the last one in the list of all the js includes.

 $(document).ready(function(){
  // Your code here
 });

make sure your function is inside the .ready main function.

It's an old post but I got here when looking for a solution so people still read it ;) I have or rather had the same problem. In my case it turned out that I was attaching js in html in wrong way (notice in what way I was ending script tag)

WRONG: <script type="text/javascript" src="/fbo/js/jquery-ui-1.8.14.custom.min.js"/>

GOOD: <script type="text/javascript" src="/fbo/js/jquery-ui-1.8.14.custom.min.js"></script>

When I was doing it in the wrong way I had the same error.

You are probably loading prototype.js or another library that uses $ as an alias.

Try to replace $ with jQuery.

发布评论

评论列表(0)

  1. 暂无评论