我尝试在模式窗口内实现日期选择器。我不知道为什么错误切换不起作用。我包括了所有头文件。我尝试了一个单独的文件,该文件可以正常工作,但是将其包含在网站中后,它却无法正常工作。
标头:
<link href="css/bootstrap.css" rel="stylesheet" />
<link href="css/landing-page.css" rel="stylesheet"/>
<link rel="stylesheet" href="assets/css/bootstrap-datetimepicker.css" media="screen">
<link rel="stylesheet" type="text/css" href="http://netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.min.css">
<link href="http://maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet">
<link href="assets/css/style.css" rel="stylesheet">
<link href="assets/css/style-responsive.css" rel="stylesheet">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="http://code.jquery.com/jquery-2.1.3.min.js"></script>
HTML代码:
<input type="text" class="form-control" placeholder="Date Of Birth" name="dateofbirth" id="dateofbirth">
脚本:
<script src="assets/js/jquery.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<script src="assets/js/jquery-1.7.1.min.js"></script>
<script src="assets/js/jquery.validate.js"></script>
<script src="js/script.js"></script>
<script type="text/javascript" src="assets/js/bootstrap-datetimepicker.js" ></script>
<script type="text/javascript" src="assets/js/jquery.backstretch.min.js"></script>
<script type="text/javascript">
$.backstretch("assets/img/login-bg1.jpg", {speed: 500});
$('#dateofbirth').datetimepicker
({
autoclose: 1,
todayHighlight: 1,
startView: 2,
minView: 3,
maxView: 4,
forceParse: 0,
format:'dd-mm-yyyy'
});
addEventListener('load', prettyPrint, false);
</script>
最佳答案
问题在于,您正在尝试将元素绑定到事件,然后再将元素和/或所需的脚本加载到页面上。
将您的JavaScript更改为此:
$(document).ready(function () {
$.backstretch("assets/img/login-bg1.jpg", {speed: 500});
$('#dateofbirth').datetimepicker
({
autoclose: 1,
todayHighlight: 1,
startView: 2,
minView: 3,
maxView: 4,
forceParse: 0,
format:'dd-mm-yyyy'
});
addEventListener('load', prettyPrint, false);
$('pre').addClass('prettyprint linenums');
});
关于jquery - jQuery Datepicker不显示,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/35363501/