我正在尝试使用此处的引导日期时间选择器: http://eonasdan.github.io/bootstrap-datetimepicker/
但我似乎无法让简单的例子运行。当我点击日历字形时,没有任何反应,我希望日期时间选择器出现! 这是源代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Template for bootstrap</title>
<link href="dependencies/bootstrap/css/bootstrap.css" rel="stylesheet">
<link href="dependencies/bootstrap-datetimepicker.min.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="dependencies/jquery/jquery-2.0.3.js"></script>
</head>
<body>
<div class="container">
<div class="col-md-10">
<div class="well">
<div class="form-group">
<div class="input-group date" id="datetimepicker1">
<input type="text" class="form-control">
<span class="input-group-addon"><span class="glyphicon-calendar glyphicon"></span>
</span>
</div>
</div>
</div>
<script type="text/javascript">
$(function() {
$('#datetimepicker1').datetimepicker();
});
</script>
</div>
</div>
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script type="text/javascript" src="dependencies/bootstrap/js/bootstrap.js"></script>
<script type="text/javascript" src="dependencies/bootstrap-datetimepicker.min.js"></script>
</body>
</html>
编辑1:我还尝试在包含js libs之后和body end标记之前调用timepicker函数,但没有成功。
<body>
<div class="container">
<div class="col-md-10">
<div class="well">
<div class="form-group">
<div class="input-group date" id="datetimepicker1">
<input type="text" class="form-control">
<span class="input-group-addon"><span class="glyphicon-calendar glyphicon"></span>
</span>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script type="text/javascript" src="dependencies/bootstrap/js/bootstrap.js"></script>
<script type="text/javascript" src="dependencies/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript">
$(function() {
$('#datetimepicker1').datetimepicker();
});
</script>
</body>
答案 0 :(得分:1)
确保资源正确链接,从外部链接下载和替换资源并使用它。试试这段代码,
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Template for bootstrap</title>
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet">
<link href="http://eonasdan.github.io/bootstrap-datetimepicker/styles/bootstrap-datetimepicker.min.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
</head>
<body>
<div class="container">
<div class="col-md-10">
<div class="well">
<div class="form-group">
<div class="input-group date" id="datetimepicker1">
<input type="text" class="form-control">
<span class="input-group-addon"><span class="glyphicon-calendar glyphicon"></span>
</span>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script type="text/javascript" src="http://eonasdan.github.io/bootstrap-datetimepicker/scripts/bootstrap.min.js"></script>
<script type="text/javascript" src="http://eonasdan.github.io/bootstrap-datetimepicker/scripts/bootstrap-datetimepicker.js"></script>
<script type="text/javascript">
$(function() {
$('#datetimepicker1').datetimepicker();
});
</script>
</body>
</html>