未定义不是日期选择器中的函数
Undefined not a function in datepicker
$('#datetimepicker1').datetimepicker();
我正在使用这段代码,并且已经定义了所有 css 和 js。即使出现此错误..
我做错了什么?
首先,您应该具有 jquery-ui
、jquery-css
和 jquery-api
的以下链接:
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
你的HTML可以是:
<p>Date: <input type="text" id="datepicker"></p>
如果您通过 id
调用 datepicker()
函数,您的脚本 应该 :
<script>
$(function() {
$("#datepicker").datepicker();
});
</script>
或者如果您想通过 class 名称调用它,它应该是:
<script>
$(function() {
$(".yourClassName").datepicker();
});
</script>
$('#datetimepicker1').datetimepicker();
我正在使用这段代码,并且已经定义了所有 css 和 js。即使出现此错误.. 我做错了什么?
首先,您应该具有 jquery-ui
、jquery-css
和 jquery-api
的以下链接:
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
你的HTML可以是:
<p>Date: <input type="text" id="datepicker"></p>
如果您通过 id
调用 datepicker()
函数,您的脚本 应该 :
<script>
$(function() {
$("#datepicker").datepicker();
});
</script>
或者如果您想通过 class 名称调用它,它应该是:
<script>
$(function() {
$(".yourClassName").datepicker();
});
</script>