最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - Can not get bootstrap datetime picker to display properly - Stack Overflow

matteradmin4PV0评论

I am trying to use BootStrap DateTimePicker and it is not displaying properly on the screen. My HTML looks like below.

<div class='input-group date' id='startDate'>
        <input type='text' class="form-control" name="startDate" />
        <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span>
</div>

And the Javascript is like below.

$(document).ready(function () {
            // DateTime picker for Dates
            $("#startDate").datetimepicker();
});

And the order in which I am loading my javascript and css files is as below.

<link href="/Content/css/datepicker.css" rel="stylesheet"/>
<link href="/Content/css/bootstrap-datetimepicker.css" rel="stylesheet"/>
<link href="/Content/css/bootstrap.css" rel="stylesheet"/>

<script src="/Scripts/jquery-2.1.0.js"></script>
<script src="/Scripts/jquery-ui-1.10.0.custom.js"></script>
<script src="/Scripts/bootstrap-datepicker.js"></script>
<script src="/Scripts/bootstrap.js"></script>
<script src="/Scripts/moment.js"></script>
<script src="/Scripts/bootstrap-datetimepicker.js"></script>

With the above set up, datetime picker is displaying as below without any proper css. The arrow buttons to change the month are not displayed correctly.

I tried changing the order, but still displaying the same. Can someone help me with what i am missing?

I am trying to use BootStrap DateTimePicker and it is not displaying properly on the screen. My HTML looks like below.

<div class='input-group date' id='startDate'>
        <input type='text' class="form-control" name="startDate" />
        <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span>
</div>

And the Javascript is like below.

$(document).ready(function () {
            // DateTime picker for Dates
            $("#startDate").datetimepicker();
});

And the order in which I am loading my javascript and css files is as below.

<link href="/Content/css/datepicker.css" rel="stylesheet"/>
<link href="/Content/css/bootstrap-datetimepicker.css" rel="stylesheet"/>
<link href="/Content/css/bootstrap.css" rel="stylesheet"/>

<script src="/Scripts/jquery-2.1.0.js"></script>
<script src="/Scripts/jquery-ui-1.10.0.custom.js"></script>
<script src="/Scripts/bootstrap-datepicker.js"></script>
<script src="/Scripts/bootstrap.js"></script>
<script src="/Scripts/moment.js"></script>
<script src="/Scripts/bootstrap-datetimepicker.js"></script>

With the above set up, datetime picker is displaying as below without any proper css. The arrow buttons to change the month are not displayed correctly.

I tried changing the order, but still displaying the same. Can someone help me with what i am missing?

Share Improve this question asked Nov 24, 2014 at 15:34 DevDev 1,5614 gold badges26 silver badges36 bronze badges 1
  • why to use both <script src="/Scripts/bootstrap-datepicker.js"></script> and <script src="/Scripts/bootstrap-datetimepicker.js"></script> ? can't you just use the datepicker script? – ymz Commented Nov 24, 2014 at 21:53
Add a ment  | 

1 Answer 1

Reset to default 4

Ok, check this fiddle:

http://jsfiddle/8hmcfmLh/1/

you don't need jquery-ui or bootstrap-datepicker, just bootstrap-datetimepicker and moment.js

<div class="input-group date" id="startDate">
        <input type="text" class="form-control" name="startDate" />
    <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
</div>

$(document).ready(function () {
    // DateTime picker for Dates
    $("#startDate").datetimepicker();
});
Post a comment

comment list (0)

  1. No comments so far