Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

datepicker is not a function

Tags:

This question is already asked many times but none of them worked for me. I am trying to use this date picker in a JSP file. This is my script

<head>
<title>My Home</title>
<link rel="stylesheet" type="text/css"
href="../resource/css/page-style.css" />
<link rel="stylesheet" type="text/css"
href="../resource/css/jQuery-ui.css" />
<script src="../resource/js/jquery-1.9.1.js"></script>
<script src="../resource/js/jquery-ui.js"></script>
<script type="text/javascript" src="../resource/js/form-elements.js"></script>

<script type="text/javascript">
$("document").ready(function() {
    $("#shortcuts").load("shortcut.html");
    $("#datepicker").datepicker();
    alert('jQuery is working');
});
</script>
</head>

The shortcut file is loading perfectly, alert is also showing. I get error message as TypeError: $(...).datepicker is not a function. I am not facing this problem if I run this script in a html file placed in my desktop, when I copy the come code to my IDE and run it I get this error in my console. Please suggest me what can I do? I know this question is asked several times I have checked every answer this is the only link having close match to my prob but didn't work for me.

like image 457
NewUser Avatar asked Mar 15 '13 06:03

NewUser


People also ask

Does bootstrap 4 have a datepicker?

Bootstrap date picker is a plugin that adds the function of selecting time without the necessity of using custom JavaScript code. This documentation may contain syntax introduced in the MDB 4.17. 0 and can be incompatible with previous versions. For old Date Picker documentation please follow the link.

How do you use a datepicker?

The datepicker is tied to a standard form input field. Focus on the input (click, or use the tab key) to open an interactive calendar in a small overlay. Choose a date, click elsewhere on the page (blur the input), or hit the Esc key to close. If a date is chosen, feedback is shown as the input's value.

What is datepicker in jQuery?

A date-picker of jQuery UI is used to provide a calendar to the user to select the date from a Calendar. This date picker usually connected to a text-box so user selection of date from the calendar can be transferred to the textbox.

What is a datepicker JS?

The JavaScript DatePicker (Calendar Picker) is a lightweight and mobile-friendly control that allows end users to enter or select a date value. It has month, year, and decade view options to quickly navigate to the desired date.


2 Answers

The problem is with your imported files.I think you have not placed them properly.

Try to import these files

 <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
  <script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>

It is working for me.

see here for more information

like image 132
PSR Avatar answered Sep 19 '22 05:09

PSR


Double check that there are no JQuery references after your JQuery-ui reference.

I had an extra JQuery reference that came after my JQuery-ui reference and lost an hour chasing the problem. That will cause the datepicker not found error.

like image 26
Mark Kadlec Avatar answered Sep 21 '22 05:09

Mark Kadlec