【发布时间】:2015-07-09 21:55:41
【问题描述】:
我刚开始使用 BootStrap,但被困在了
Uncaught TypeError: $(...).datetimepicker is not a function 错误消息。有人可以告诉我这段代码缺少什么吗?
从那时起,已经提到了多个类似的问题,但都无济于事。
home_page.html
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Health Insurance</title>
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/bootstrap-theme.css">
<link rel="stylesheet" href="js/bootstrap-datepicker.min.css">
<link rel="stylesheet" href="css/bootstrap.css">
</head>
<body>
<form role="form">
<div class="form-group form-group-sm">
<label class="col-sm-2 control-label" for="insuredName">Insured Name :</label>
<div class="col-sm-3">
<input class="form-control" type="text" id="insuredName" placeholder="Insured Name">
</div>
</div>
<div class="form-group form-group-sm">
<label class="col-sm-2 control-label" for="rel_PolicyHolder">Relation with Policy Holder :</label>
<div class="col-sm-3">
<input class="form-control" type="text" id="rel_PolicyHolder" placeholder="Relation with Policy Holder"> <br />
<br />
</div>
</div>
<div class="container" >
<div class="col-sm-4" style="height:130px; align:right">
<div class='input-group date'>
<input type='text' class="form-control" id='datetimepicker9' />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
<script src="js/jquery-1.11.2.min.js"></script></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/bootstrap-datepicker.min.js"></script>
<script type="text/javascript">
$(function () {
$('#datetimepicker9').datetimepicker({
viewMode: 'years'
});
});
</script>
</div>
</div>
</div>
</form>
</body>
</html>
所有文件都放在 Eclipse 的 WebContent 文件夹下,但 outside 的 META-INF > 和 WEB-INF 文件夹。
css 文件夹
- bootstrap-theme.css
- bootstrap-theme.css.map
- bootstrap-theme.min.css
- bootstrap.css
- bootstrap.css.map
- bootstrap.min.css
- enhanced.css
- jquery-ui.css
- ui.daterangepicker.css
fonts 文件夹
- glyphicons-halflings-regular.eot
- glyphicons-halflings-regular.svg
- glyphicons-halflings-regular.ttf
- glyphicons-halflings-regular.woff
- glyphicons-halflings-regular.woff2
js 文件夹
- bootstrap-datepicker.min.css
- bootstrap-datepicker.min.js
- bootstrap.js
- bootstrap.min.js
- date.js
- enhance.min.js
- fileinput.jquery.js
- jquery-1.11.2.min.js
- jquery-1.8.3.min.js
- jquery-1.9.0.min.js
- jquery-ui.js
- npm.js
错误信息
Uncaught TypeError: $(...).datetimepicker is not a function
(anonymous function) @ home_page.html:82
m.Callbacks.j @ jquery-1.11.2.min.js:2
m.Callbacks.k.fireWith @ jquery-1.11.2.min.js:2
m.extend.ready @ jquery-1.11.2.min.js:2
J @ jquery-1.11.2.min.js:2
任何指导都值得关注
【问题讨论】:
-
您正在加载
bootstrap-datepicker,但使用的是datetimepicker。这是两个单独的包。 -
它是
$( ... ).datepicker({ options })。阅读bootstrap-datepicker.readthedocs.org/en/latest(也在项目自述文件中) -
@Andy 不,我在 BS3 中使用该项目,因为我输入了这个,而且绝对是
datepicker。 - 该 repo 包含 2 和 3 代码。 -
你在使用
http://eonasdan.github.io/bootstrap-datetimepicker/Installing/吗? -
@h2ooooooo - 现在不再显示错误。
Could you please help me now to realign the date-picker text box so that it goes in tandem with the previous row text-box.
标签: javascript jquery html css twitter-bootstrap