Search code examples
javascriptjquerydatepickerjquery-ui-datepickeruidatepicker

how to fix 'Uncaught TypeError: $(...).datepicker is not a function'


i want create datepicker but it is not working

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

Uncaught TypeError: $(...).datepicker is not a function

I expected calendar, but it shows me an error


Solution

  • Do you have both jQueryui AND jQuery included in your scripts somewhere? Question is a little vague without source code or more information to what you're doing.

    This is taken straight from jQueryUI's website: https://jqueryui.com/datepicker/

    Also, make sure that jQuery is not included twice in your code as this post suggest: jQuery UI " $("#datepicker").datepicker is not a function"

    Possible duplicate of:

    <!doctype html>
    <html lang="en">
    <head>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <title>jQuery UI Datepicker - Default functionality</title>
      <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
      <link rel="stylesheet" href="/resources/demos/style.css">
      <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
      <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
      <script>
      $( function() {
        $( "#datepicker" ).datepicker();
      } );
      </script>
    </head>
    <body>
     
    <p>Date: <input type="text" id="datepicker"></p>
     
     
    </body>
    </html>

    Hope this helps!