i am new to bootstrap, i am trying to implement bootstrap date picker, but somehow it is not happening. Can you please check which code of mine is going wrong. below is my .html file
我是bootstrap的新手,我正在尝试实现引导日期选择器,但不知何故它没有发生。你能否检查我的哪些代码出错了?下面是我的.html文件
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
</head>
<body>
<div class="container">
<div class='input-group date' id='datetimepicker1'>
<input type='text' class="form-control" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
<script type="text/javascript">
$(function () {
$('#datetimepicker1').datetimepicker();
});
</script>
</body>
</html>
3 个解决方案
#1
0
i think you are missing the DateTimepicker scripts please include this scripts
我想你错过了DateTimepicker脚本请包括这个脚本
<script src="js/jquery-1.9.1.min.js"></script>
<script src="js/bootstrap-datepicker.js"></script>
and you can just go through the demo http://code.runnable.com/UmOlOZbXvZRqAABU/bootstrap-datepicker-example-text-input-with-specifying-date-format2
你可以通过演示http://code.runnable.com/UmOlOZbXvZRqAABU/bootstrap-datepicker-example-text-input-with-specifying-date-format2
#2
0
somehow i got the work around.. but still it has some issues with time, if anyone has a better solution please post it
不知怎的,我得到了解决方案..但它仍有一些时间问题,如果有人有更好的解决方案,请发布它
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/css/bootstrap-datetimepicker.css" rel="stylesheet" type="text/css"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/js/bootstrap-datetimepicker.min.js"></script>
</head>
<body>
<div class="container">
<div class='input-group date' id='datetimepicker1'>
<input type='text' class="form-control" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
<script type="text/javascript">
$(function () {
$('#datetimepicker1').datetimepicker();
});
</script>
</body>
</html>
#3
0
Change this:
$(function () {
$('#datetimepicker1').datetimepicker();
});
to this:
jQuery(function($) {
$('#datetimepicker1').datetimepicker();
});
Reason:
Many JavaScript libraries use $
as a function or variable name, just as jQuery does. In order to avoid conflicts, you need to specify the library alias of $
which in jQuery's case, $
is just an alias for jQuery
.
许多JavaScript库使用$作为函数或变量名,就像jQuery一样。为了避免冲突,你需要指定$的库别名,在jQuery的情况下,$只是jQuery的别名。
#1
0
i think you are missing the DateTimepicker scripts please include this scripts
我想你错过了DateTimepicker脚本请包括这个脚本
<script src="js/jquery-1.9.1.min.js"></script>
<script src="js/bootstrap-datepicker.js"></script>
and you can just go through the demo http://code.runnable.com/UmOlOZbXvZRqAABU/bootstrap-datepicker-example-text-input-with-specifying-date-format2
你可以通过演示http://code.runnable.com/UmOlOZbXvZRqAABU/bootstrap-datepicker-example-text-input-with-specifying-date-format2
#2
0
somehow i got the work around.. but still it has some issues with time, if anyone has a better solution please post it
不知怎的,我得到了解决方案..但它仍有一些时间问题,如果有人有更好的解决方案,请发布它
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/css/bootstrap-datetimepicker.css" rel="stylesheet" type="text/css"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/js/bootstrap-datetimepicker.min.js"></script>
</head>
<body>
<div class="container">
<div class='input-group date' id='datetimepicker1'>
<input type='text' class="form-control" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
<script type="text/javascript">
$(function () {
$('#datetimepicker1').datetimepicker();
});
</script>
</body>
</html>
#3
0
Change this:
$(function () {
$('#datetimepicker1').datetimepicker();
});
to this:
jQuery(function($) {
$('#datetimepicker1').datetimepicker();
});
Reason:
Many JavaScript libraries use $
as a function or variable name, just as jQuery does. In order to avoid conflicts, you need to specify the library alias of $
which in jQuery's case, $
is just an alias for jQuery
.
许多JavaScript库使用$作为函数或变量名,就像jQuery一样。为了避免冲突,你需要指定$的库别名,在jQuery的情况下,$只是jQuery的别名。