简体   繁体   中英

jquery timepicker not displaying 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.

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.com/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> 

确保没有css定义,可能会隐藏此元素。

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