简体   繁体   中英

Bootstrap-Datepicker not working properly

My bootstrap-datetimepicker is not working properly
This question has been asked a lot of times here, but the answers from here , here and here and manny others didn't help me further...

at the top of my webpage in the <head> i'm including:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.4/js/bootstrap-datepicker.min.js"></script>

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1">

and then in my form i want to call him like this:

<div class="col-md-4">
    <label class="control-label" for="birthday">Birthday:</label>
       <div class="form-group">
          <div class='input-group date' id='datetimepicker'>
              <input type='text' class="form-control" placeholder="dd/mm/yyyy" value="" />
              <span class="input-group-addon">
                 <span class="glyphicon glyphicon-calendar"></span>
              </span>
           </div>
       </div>
</div>

and at the bottom before the </body> tag there is the javascript/jquery part:

<script type="text/javascript">
   $('#datetimepicker').datepicker();
</script>

What am i doing wrong ? Can someone correct my mistakes ?

Try wrap plugin initialization in document ready function .

<script type="text/javascript">
    $(document).ready(function() {
        $('#datetimepicker').datepicker();
    });
</script>

i've read that bootstrap datepicker requires jquery 1.7.1 and up

check this fiddle im using jquery 1.9.1

<div class="col-md-4">
    <label class="control-label" for="birthday">Birthday:</label>
       <div class="form-group">
          <div class='input-group date' id='datetimepicker'>
              <input type='text' class="form-control" placeholder="dd/mm/yyyy" value="" />
              <span class="input-group-addon">
                 <span class="glyphicon glyphicon-calendar"></span>
              </span>
           </div>
       </div>
</div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM