Eonasdan Bootstrap 日期时间选择器不工作

Eonasdan Bootstrap datetimepicker is not working

在我的 _Layout 视图中,我将其作为脚本(还添加了 CSS):

<!-- jQuery -->
        <script src="/Content/themes/sb-admin-2/jquery/dist/jquery.min.js"></script>
        <!-- Bootstrap Core JavaScript -->
        <script src="/Content/themes/sb-admin-2/bootstrap/dist/js/bootstrap.min.js"></script>
        <!-- Morris Charts JavaScript -->
        <script src="/Content/themes/sb-admin-2/raphael/raphael-min.js"></script>
        <script src="/Content/themes/sb-admin-2/morrisjs/morris.min.js"></script>
        <script src="/Content/themes/sb-admin-2/js/morris-data.js"></script>
        <!-- Moment -->
        <script src="/Scripts/moment-with-locales.min.js"></script>
        <!-- DateTimePicker -->
        <script src="/Content/datetimepicker/bootstrap-datetimepicker.js"></script>
       
       
        <!-- Custom Theme JavaScript -->
        <script src="/Content/themes/sb-admin-2/js/sb-admin-2.js"></script>

<script>

    $(document).ready(function () {
        debugger;
        $('.datetimepicker').datetimepicker({


            sideBySide: true
        });
    });

</script>

而且,在我想显示日期时间选择器的地方,我有这个:

<div class="row">
                    <div class="form-group col-md-6">
                        <label>Publish Date</label>
                        <div class="input-group" id="datetimepicker">
                            @Html.TextBoxFor(x => x.PublishDate, new { @class = "form-control datetimepicker", placeholder = "Date", required = "required" })
                            <div class="input-group-addon"><i class="fa fa-calendar"> </i></div>
                        </div>
                    </div>
                </div>

我尝试了很多方法来显示日期时间选择器,有人知道我的问题吗?我没有在控制台中抛出错误,我尝试调试但什么也没找到。

您的 div 有 id="datetimepicker" 但您正在使用 class “.datetimepicker”的选择器。 尝试改变:

$('.datetimepicker').datetimepicker({ sideBySide: true });

进入

$('#datetimepicker').datetimepicker({ sideBySide: true });