【问题标题】:$(...).datepicker is not a function$(...).datepicker 不是函数
【发布时间】:2016-09-12 03:59:45
【问题描述】:

Datepicker 无法在此页面运行,但导入了 jquery-ui 的脚本。 冲突在哪里?谢谢。 日期选择器不是函数 这是我的脚本

$( document ).ready(function() {    
    var fecha = "";
   $( "#datepicker" ).datepicker({
       dateFormat: "yy-mm-dd",
   });
});

$( "#datepicker" ).change(function(){
    fecha = this.value;
    $.post( "tablaUsuarioPlanta.php",{fecha : fecha},function(data){
       $("#tabla").html(data);
    });
});    

这是 HTML

<p>Date: <input type="text" id="datepicker" size="30"></p>

脚本加载到页面上

<script  src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js">    </script>


<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
<!-- Bootstrap Core CSS -->
<link href="../css/bootstrap.min.css" rel="stylesheet">

<!-- Custom CSS -->
<link href="../css/simple-sidebar.css" rel="stylesheet">

<!--JQUERY-->
<!--<script src="../js/jquery.js"></script>-->

<link rel="stylesheet"          href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>

【问题讨论】:

  • 你为什么添加了两次code.jquery.com/ui/1.10.2/jquery-ui.js文件???
  • 检查您是否在 datepicker 代码之后不加载 jquery 和 jquery-ui 库。 JSfiddle 的例子最好。

标签: javascript jquery html


【解决方案1】:

您正在使用两个版本的 JQuery 来创建冲突。只使用一个而不是两个。

 <script  src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"> </script>
<link href="../css/bootstrap.min.css" rel="stylesheet">
<!-- Custom CSS -->
<link href="../css/simple-sidebar.css" rel="stylesheet">
<!--JQUERY-->
<link rel="stylesheet"          href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>

【讨论】:

  • @AntonioSanz 欢迎
猜你喜欢
  • 2017-10-13
  • 1970-01-01
  • 2019-06-16
  • 2012-03-17
  • 1970-01-01
  • 2020-10-07
  • 1970-01-01
  • 2010-11-15
相关资源
最近更新 更多