不显示Jquery Datepicker

时间:2016-02-12 13:11:57

标签: jquery twitter-bootstrap datepicker

我尝试在模态窗口中实现一个日期选择器。我不知道为什么错误切换不起作用。我包括了所有的头文件。我尝试了一个正常工作的单独文件,但是在我将它包含在我的网站后它没有用。

接头:

<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>

2 个答案:

答案 0 :(得分:1)

更改

cmd /c echo Y| cacls ....

$('#dateofbirth').datetimepicker()

我在jsbin上有一个工作示例。您可以查看此here

您可以查看其整页输出here

答案 1 :(得分:1)

问题是您在将元素和/或所需脚本加载到页面之前尝试将元素绑定到事件。

将您的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');
    });