Why does jqueryUI datepicker throw an error?

I am trying to execute jqueryUI, but firebug catches the following error in this script:

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

The firebug error says:

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

In my html, the identifier "date" looks like this:

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

NB: I used the correct jqueryUI css / js scripts in the section

Does nothing ...

+3
source share
6 answers

The jQuery documentation says that you can call datepicker with this command:

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

If you click the "View Source" button on the documentation page, you will see that they wrapped it in a ready-made function:

$(document).ready(function(){
    $("#datepicker").datepicker();
  });

EDIT: INPUT (, Steerpike). , , , :

<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>
+3

datepicker . , , , javascript.

, jquery google api.

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

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

, jquery ui js.

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

, .ready.

+1

This is an old post, but I came here when I was looking for a solution so that people would still read it;) I had or not the same problem. In my case, it turned out that I did not properly bind js in html (note how I ended the tag script)

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 did it wrong, I had the same error.

+1
source

Perhaps you download prototype.js or another library that uses $ as an alias.

Try replacing $ with jQuery.

0
source

Source: https://habr.com/ru/post/1705856/


All Articles