简体   繁体   English

如何在HTML页面中放置datetimepicker?

[英]How to place a datetimepicker in html page?

I have all of these files in my website header: 我的网站标题中包含所有这些文件:

<script src="https://code.jquery.com/jquery-3.3.1.js" integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60=" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js" integrity="sha256-T0Vest3yCU7pafRw9r+settMBX6JkKN06dqBnpQ8d30="crossorigin="anonymous"></script>
<script src="http://localhost:8080/Javascript/bootstrap.bundle.js" type="javascript/text"></script>
<link rel="stylesheet" href="http://localhost:8080/Css/bootstrap.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.8.0/css/bootstrap-datepicker.css"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.8.0/js/bootstrap-datepicker.js" type="javascript/text"></script>

Then I have the following in my body: 然后我的体内有以下东西:

<div class="container-fluid">
    <div class="row">
        <div class="col-md-6 col-sm-6 col-xs-12">

            <!-- Form code begins -->
            <form method="post">
                <div class="form-group"> <!-- Date input -->
                    <label class="control-label" for="date">Date</label>
                    <input class="form-control" id="date" name="date" placeholder="MM/DD/YYY" type="text"/>
                </div>
                <div class="form-group"> <!-- Submit button -->
                    <button class="btn btn-primary " name="submit" type="submit">Submit</button>
                </div>
            </form>
            <!-- Form code ends --> 
        </div>
    </div>    
</div>

<script>
    $(document).ready(function(){
        $("#date").datepicker();
    });
</script>

I want it to look like this: https://formden.com/blog/date-picker . 我希望它看起来像这样: https : //formden.com/blog/date-picker

But instead it looks like this: 但是它看起来像这样:

What do I do? 我该怎么办? I have been trying for hours. 我已经尝试了几个小时。 I have tried different ordering of the files. 我尝试了文件的不同排序。 When I try to do datetimepicker() . 当我尝试做datetimepicker() I get an error. 我得到一个错误。 I just do not know what to do please help. 我只是不知道该怎么办,请帮忙。

It looks like you are Using JqueryUI as well as BootstrapDatepicker. 看起来您正在使用JqueryUI以及BootstrapDatepicker。 Since bootstrapDatepicker and JqueryUI both has got the same function name for their datepicker to be initialized hence there is an ambiguity. 由于bootstrapDatepicker和JqueryUI都为初始化的日期选择器获得了相同的函数名,因此存在歧义。 Now your markup has got jqueryUI js loaded first so it is ideally using the jqueryUI datepicker function and expecting the CSS of jqueryUI which can be found here . 现在,您的标记首先加载了jqueryUI js,因此理想情况下,它是使用jqueryUI datepicker函数并期望可以在此处找到jqueryUI的CSS。

If you want to use the bootstrap datepicker then you might need to remove the jqueryUI.js or generate the jqueryUI js which is excluding the datepicker functionality. 如果要使用引导日期选择器,则可能需要删除jqueryUI.js或生成不包含日期选择器功能的jqueryUI js。

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

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