如何使用jQuery UI datepicker.format

问题描述 投票:0回答:4

以下结果为:Uncaught TypeError: Cannot read property 'formatDate' of undefined我在同一个目录中有所有三个文件(jquery,jquery-ui和此html文件):

<html>
<head>
<link rel="stylesheet" href="jquery-ui.min.css">
<script src="jquery-1.11.1.min.js"</script>
<script src="jquery-ui.min.js"</script>
<script>
$(document).ready(function(){
  var $t = $.datepicker.formatDate("M dd", new Date("2014-12-01"));
  console.log($t);
});
</script>
</head>
<body>
</body>
</html>

我在做什么错?

javascript jquery jquery-ui jquery-ui-datepicker
4个回答
2
投票
<script src="jquery-1.11.1.min.js"></script> <script src="jquery-ui.min.js"></script>

您没有正确加载jquery-ui。您需要一个右括号。


1
投票
HTML:

0
投票
<script src="//code.jquery.com/jquery-1.10.2.js"></script> <script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script> <link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css"> <script> $(function() { $( "#your_input" ).datepicker(); }); </script>

可选的快速加载数据选择器:

      <script src="//code.jquery.com/jquery-1.10.2.js"></script>
      <script src="//code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
      <link rel="stylesheet" href="//code.jquery.com/ui/1.11.2/themes/smoothness/jquery-ui.css">
      <script>
      $(function() {
        $('body').on('focus',"#your_input", function(){
              $(this).datepicker({ dateFormat: 'dd-mm-yy' });
        });
      });
      </script>

我通过使用FULL datepicker js文件提出了相同的错误


0
投票
© www.soinside.com 2019 - 2024. All rights reserved.