简体   繁体   English

使jQuery timepicker工作

[英]getting jquery timepicker working

I'm new to jquery and can't seem to get this basic timepicker working: https://github.com/jonthornton/jquery-timepicker#timepicker-plugin-for-jquery 我是jquery新手,似乎无法使用此基本时间选择器: https//github.com/jonthornton/jquery-timepicker#timepicker-plugin-for-jquery

In scripts (I renamed the folder): 在脚本中(我将文件夹重命名):

<script src="@Url.Content("~/Scripts/jquery-timepicker/jquery.timepicker.js")" type="text/javascript"></script>
<script type="text/javascript">
$(function () {

    $('#AddJustPlayForm_Time').timepicker();
})

In html: 在html中:

  @Html.EditorFor(m => m.AddJustPlayForm.Time, "BootstrapHorizontalTime", new { @class = "time-picker", style = "width:100px" })

What am I doing wrong please? 请问我做错了什么?

You want to target .time-picker class rather than the field name for AddJustPlayForm.Time 您要定位.time-picker类而不是AddJustPlayForm.Time的字段名

Try 尝试

$(function () {

    $('.time-picker').timepicker();
})

You should also include the css in header. 您还应该在标头中包含css。

I found the problem. 我发现了问题。 I had the timepicker script before the main jquery script, so it wasn't able to access the main jquery library or something along those lines. 我在主jquery脚本之前有timepicker脚本,因此它无法访问主jquery库或类似的东西。 Thanks for help anyway. 无论如何,谢谢您的帮助。

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

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