简体   繁体   English

jQuery的时间选择器不显示下拉菜单

[英]jquery timepicker not displaying dropdown

I am using jquery-timepicker , and it is not displaying the dropdown when I click on the input box. 我正在使用jquery-timepicker ,单击输入框时未显示下拉列表。 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. 我知道它正在正确加载,因为当我单击输入框时,会将ui-timepicker元素添加到DOM中,并且当它失去焦点时,它会格式化在框中输入的时间。 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. 我包括以下依赖项:jQuery,jQuery timepicker和Bootstrap timepicker。 The last two have CSS and JS files too. 最后两个也有CSS和JS文件。

 $(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定义,可能会隐藏此元素。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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