Bootstrap-datetimepicker在IE8中不起作用?

时间:2015-04-18 05:10:14

标签: jquery twitter-bootstrap internet-explorer-8 datetimepicker

我正在使用bootstrap-datetimepicker,但遗憾的是日期选择器在IE8中无效,而所有其他更高版本都正常运行。

如何在IE8中修复它?

<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="js/main.js"></script>
<!-- for bootstrap calendar -->
<script type="text/javascript" src="javascripts/moment.js"></script>
<script type="text/javascript" src="javascripts/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="https://raw.githubusercontent.com/es-shims/es5-shim/master/es5-shim.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>

1 个答案:

答案 0 :(得分:3)

 $(function() {
   $(document).click(function(e){
        var target = $(e.target);
        if(target.parents('.bootstrap-datetimepicker-widget').length < 1 && !target.hasClass('datetimepickerInput') && !target.hasClass('datepickerIcon') && !target.hasClass('clockpickerIcon')){
            if($('.bootstrap-datetimepicker-widget').length > 0){
                $('#startDate').data('DateTimePicker').hide();
                $('#startTime').data('DateTimePicker').hide();
                $('.datetimepickerInput').blur();
            }
        }
    });
   $('#datetimepicker1').datetimepicker();
 });
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<link href="//cdn.rawgit.com/Eonasdan/bootstrap-datetimepicker/d004434a5ff76e7b97c8b07c01f34ca69e635d97/build/css/bootstrap-datetimepicker.css" rel="stylesheet">


<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.2/moment.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/es5-shim/4.1.1/es5-shim.min.js"></script>
<!-- Latest compiled and minified CSS -->


<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>

<!-- for bootstrap calendar -->

<script src="//cdn.rawgit.com/Eonasdan/bootstrap-datetimepicker/d004434a5ff76e7b97c8b07c01f34ca69e635d97/src/js/bootstrap-datetimepicker.js"></script>

<div class="container">
  <div class="row">
    <div class='col-sm-6'>
      <div class="form-group">
        <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>
    </div>

  </div>
</div>