admin管理员组

文章数量:1391733

I am using jquery-timepicker, and it is not displaying the dropdown when I click on the input box. In my view:

<script type="text/javascript">
$(function(){
    $('#StartTime').timepicker(); 
});
</script>
/* ... */
<div class="col-xs-6 form-group">
    <label>Start Time:</label>
        <div class="input-group">
            <input type="text" class="form-control"  id="StartTime" />
            <span class="input-group-addon"><i class="fa fa-clock-o"></i></span>
        </div>
</div>

I know it is loading properly, because the ui-timepicker element is being added to the DOM when I click on the input box and it formats time entered in the box when it loses focus. It just isn't displaying the dropdown.

I am using jquery-timepicker, and it is not displaying the dropdown when I click on the input box. In my view:

<script type="text/javascript">
$(function(){
    $('#StartTime').timepicker(); 
});
</script>
/* ... */
<div class="col-xs-6 form-group">
    <label>Start Time:</label>
        <div class="input-group">
            <input type="text" class="form-control"  id="StartTime" />
            <span class="input-group-addon"><i class="fa fa-clock-o"></i></span>
        </div>
</div>

I know it is loading properly, because the ui-timepicker element is being added to the DOM when I click on the input box and it formats time entered in the box when it loses focus. It just isn't displaying the dropdown.

Share Improve this question asked Nov 8, 2015 at 20:20 Musical ShoreMusical Shore 1,3813 gold badges20 silver badges42 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

Check that you have all the dependencies. I copied your code to a snippet and added the dependencies from the official site and it worked well. I included the following dependencies: jQuery, jQuery timepicker and Bootstrap timepicker. The last two have CSS and JS files too.

$(function() {
  $('#StartTime').timepicker();
});
<script type="text/javascript" src="https://ajax.googleapis./ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript" src="https://jonthornton.github.io/jquery-timepicker/jquery.timepicker.js"></script>
<link rel="stylesheet" type="text/css" href="https://jonthornton.github.io/jquery-timepicker/jquery.timepicker.css">
<script type="text/javascript" src="https://jonthornton.github.io/jquery-timepicker/lib/bootstrap-datepicker.js"></script>
<link rel="stylesheet" type="text/css" href="https://jonthornton.github.io/jquery-timepicker/lib/bootstrap-datepicker.css">

<div class="col-xs-6 form-group">
  <label>Start Time:</label>
  <div class="input-group">
    <input type="text" class="form-control" id="StartTime" />
    <span class="input-group-addon"><i class="fa fa-clock-o"></i></span>
  </div>
</div>

Make sure there is no css definitions, which may hide this element.

本文标签: javascriptjquery timepicker not displaying dropdownStack Overflow