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

javascript - How to use JQuery DateTime Picker? - Stack Overflow

programmeradmin1浏览0评论

I am a beginner programmer and I'm trying to make a web page that displays a JQuery Inline Date and Time Picker. As I was researching, I found this documentation: DateTimePicker. I followed the steps of first importing the JS and CSS files (after the closing body tag) using these tags:

<link rel="stylesheet" type="text/css" href="jquery.datetimepicker.css"/ >
<script src="jquery.js"></script>
<script src="jquery.datetimepicker.js"></script>

Following those tags, I called on my <input> from my Home.html file with the id of datetimepicker. Then using that id, I copied the code from the tutorial that creates the Inline DateTime Picker Calendar, like so:

  $('#datetimepicker').datetimepicker({
     inline:true
  });

So my Home.html file looks like this:

<!DOCTYPE html>
<html>
 <head>
   <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
   <meta charset="utf-8">

   <title>Home</title>
   <!-- Compiled and minified CSS -->
   <link rel="stylesheet" href=".97.0/css/materialize.min.css">

   <!-- Compiled and minified JavaScript -->
   <script src=".97.0/js/materialize.min.js"></script>

   <link rel="stylesheet" type="text/css" href="./jquery.datetimepicker.css"/>
   <script src="//code.jquery/jquery-1.10.2.js"></script>

 </head>
 <body>
     <h3>Inline DateTimePicker</h3>
     <input type="text" id="datetimepicker"/><input type="button" onclick="$('#datetimepicker3').datetimepicker({value:'2011/12/11 12:00'})" value="set inline value 2011/12/11 12:00"/><br><br>
 </body>
 <!-- CALLS JQUERY LIBRARY FOR DATE AND TIME PICKER -->
 <!-- this should go after your </body> -->
  <link rel="stylesheet" type="text/css" href="jquery.datetimepicker.css"/ >
  <script src="./jquery.js"></script>
  <script src="./jquery.datetimepicker.js"></script>
  <script>
      $('#datetimepicker').datetimepicker({
        inline:true
      });
  </script>
</html>

However, when I run this code, I get an error that says:

TypeError: 'undefined' is not a function (evaluating '$('#datetimepicker').datetimepicker({
    inline:true
  })')

This is what is displaying:

This is what I want to display:

How can I get an Inline calendar to display on my Home.html page?

I am a beginner programmer and I'm trying to make a web page that displays a JQuery Inline Date and Time Picker. As I was researching, I found this documentation: DateTimePicker. I followed the steps of first importing the JS and CSS files (after the closing body tag) using these tags:

<link rel="stylesheet" type="text/css" href="jquery.datetimepicker.css"/ >
<script src="jquery.js"></script>
<script src="jquery.datetimepicker.js"></script>

Following those tags, I called on my <input> from my Home.html file with the id of datetimepicker. Then using that id, I copied the code from the tutorial that creates the Inline DateTime Picker Calendar, like so:

  $('#datetimepicker').datetimepicker({
     inline:true
  });

So my Home.html file looks like this:

<!DOCTYPE html>
<html>
 <head>
   <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
   <meta charset="utf-8">

   <title>Home</title>
   <!-- Compiled and minified CSS -->
   <link rel="stylesheet" href="https://cdnjs.cloudflare./ajax/libs/materialize/0.97.0/css/materialize.min.css">

   <!-- Compiled and minified JavaScript -->
   <script src="https://cdnjs.cloudflare./ajax/libs/materialize/0.97.0/js/materialize.min.js"></script>

   <link rel="stylesheet" type="text/css" href="./jquery.datetimepicker.css"/>
   <script src="//code.jquery./jquery-1.10.2.js"></script>

 </head>
 <body>
     <h3>Inline DateTimePicker</h3>
     <input type="text" id="datetimepicker"/><input type="button" onclick="$('#datetimepicker3').datetimepicker({value:'2011/12/11 12:00'})" value="set inline value 2011/12/11 12:00"/><br><br>
 </body>
 <!-- CALLS JQUERY LIBRARY FOR DATE AND TIME PICKER -->
 <!-- this should go after your </body> -->
  <link rel="stylesheet" type="text/css" href="jquery.datetimepicker.css"/ >
  <script src="./jquery.js"></script>
  <script src="./jquery.datetimepicker.js"></script>
  <script>
      $('#datetimepicker').datetimepicker({
        inline:true
      });
  </script>
</html>

However, when I run this code, I get an error that says:

TypeError: 'undefined' is not a function (evaluating '$('#datetimepicker').datetimepicker({
    inline:true
  })')

This is what is displaying:

This is what I want to display:

How can I get an Inline calendar to display on my Home.html page?

Share Improve this question edited Aug 12, 2015 at 14:20 user3692825 asked Aug 12, 2015 at 13:54 user3692825user3692825 1263 gold badges5 silver badges13 bronze badges 2
  • You have referenced jquery twice – Mladen Oršolić Commented Aug 12, 2015 at 13:59
  • I am using Google Maps API and if I delete the first one I referenced, the map doesn't load. If I delete the second one, the calendar still does not load. – user3692825 Commented Aug 12, 2015 at 14:09
Add a ment  | 

4 Answers 4

Reset to default 1

Put

<link rel="stylesheet" type="text/css" href="jquery.datetimepicker.css"/ >    
<script src="./jquery.datetimepicker.js"></script>

between your <head></head> tags and remove

<script src="./jquery.js"></script>

I had the same sort of issue , If download the the source code from the XDSoft site

there is build folder , try using jquery.datetimepicker.full.js file from build folder .

You need to include jquery-ui.js

Do not confuse between jQuery versions. You first referenced jQuery here:

<script src="//code.jquery./jquery-1.10.2.js"></script>

And then you are doing it here:

<script src="./jquery.js"></script>

Please remove one. As the newer jQuery will be active and it doesn't have the plugin registered.

发布评论

评论列表(0)

  1. 暂无评论