【发布时间】:2017-12-21 18:21:14
【问题描述】:
我正在尝试在联系表单中包含一个 jquery datepicker。
不幸的是,由于未知原因它无法正常工作(它正在同一站点上的其他表单中工作)
有人可以帮助澄清为什么它不起作用吗?它现在只是充当一个文本框,没有任何弹出窗口:
请注意:表格存储在卡片中,不确定这是否会影响它,但我听说表格和卡片不能很好地混合
脚本:
<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({
dateFormat: "yy-mm-dd"
});
} );
</script>
<div class="form-group">
<label for="datepicker">Pick a date</label>
<input type="text" date-date-format="yy-mm-dd" name="datepicker"
id="datepicker" class="form-control">
</div>
控制台返回:
Uncaught TypeError: $(...).datepicker is not a function at HTML 文档。 (index.php:20) 着火 (jquery-1.12.4.js:3232) 在 Object.fireWith [as resolveWith] (jquery-1.12.4.js:3362) 在 Function.ready (jquery-1.12.4.js:3582) 在 HTMLDocument.completed (jquery-1.12.4.js:3617)
【问题讨论】:
-
您确定这是标记中唯一具有该 id 的元素吗?
-
控制台有没有说什么?
-
实际上并没有考虑检查控制台。它说:Uncaught TypeError: $(...).datepicker is not a function at HTMLDocument.
(index.php:20) at fire (jquery-1.12.4.js:3232) at Object.fireWith [as resolveWith] (jquery-1.12.4.js:3362) 在 Function.ready (jquery-1.12.4.js:3582) 在 HTMLDocument.completed (jquery-1.12.4.js:3617) -
嗨亚当,是的,这是唯一具有日期选择器 ID 的元素
标签: php jquery html jquery-ui-datepicker