简体   繁体   English

错误“未捕获的TypeError:$(...)。datetimepicker不是函数”

[英]Error “Uncaught TypeError: $(…).datetimepicker is not a function”

I am trying to display two datetimepickers but i'm getting the error "Uncaught TypeError: $(...).datetimepicker is not a function" . 我试图显示两个datetimepickers,但我收到错误“Uncaught TypeError:$(...)。datetimepicker不是一个函数”。 I've installed : 我安装了:

Install-Package Bootstrap.v3.Datetimepicker Install-Package Bootstrap.v3.Datetimepicker

Install-Package Bootstrap.v3.Datetimepicker.CSS Install-Package Bootstrap.v3.Datetimepicker.CSS

Here is the code : 这是代码:

@model MVCGreenhouseMonitoring.Models.Plotting.PlottingCalendarDropDownList
<head>
    <title></title>
    <script src="~/Scripts/jquery-1.9.1.js"></script>
    <script src="~/Scripts/jquery-ui-1.11.4.min.js"></script>
    <script src="~/scripts/moment-with-locales.min.js"></script>
    <script src="~/scripts/bootstrap.min.js"></script>
    <script src="~/scripts/bootstrap-datetimepicker.js"></script>
    <link rel="stylesheet" href="~/Content/bootstrap-datetimepicker.css" />

</head>
<script>
    $(function () {
        $("#txtdatepicker1").datetimepicker();
        $("#txtdatepicker2").datetimepicker();
    });
</script>

@using (Html.BeginForm("IntervalReports", "Greenhouse", FormMethod.Post))
{
    <table>
        <tr>
            <td>
                <p>
                    Start Date: @Html.TextBoxFor(m => m.StartDateCalendar, new { @id = "txtdatepicker1", @style = "width:200px;" })
                </p>
            </td>
            <td>
                <p>
                    End Date: @Html.TextBoxFor(m => m.EndDateCalendar, new { @id = "txtdatepicker2", @style = "width:200px;" })
                </p>
            </td>
        </tr>
    </table>
    <input type="submit" name="btnSubmit" value="Submit" />
}

I have all the necessary scripts in the Scripts folder. 我在Scripts文件夹中有所有必需的脚本。

Just include this on top of the other js files: 只需将其包含在其他js文件之上:

<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>

And wrap your script like this: 并像这样包装你的脚本:

jQuery(document).ready(function($){
        jQuery("#txtdatepicker1").datetimepicker();
        jQuery("#txtdatepicker2").datetimepicker();
});

确保你包含正确的jquery脚本路径,并且必须是html的head标签中的第一个,你可以在这里获得最新的jquery脚本https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/ jquery.min.js

You need to include the jQuery library before you can use jQuery UI n your page. 您需要先包含jQuery库,然后才能在页面中使用jQuery UI。

How to use jQuery UI 如何使用jQuery UI

Like this 像这样

<link rel="stylesheet" href="jquery-ui.min.css">
<script src="external/jquery/jquery.js"></script>
<script src="jquery-ui.min.js"></script>

jQuery UI is dependant on the jQuery library. jQuery UI依赖于jQuery库。

jQuery UI is a widget and interaction library built on top of the jQuery JavaScript Library that you can use to build highly interactive web applications. jQuery UI是一个构建在jQuery JavaScript库之上的小部件和交互库,可用于构建高度交互的Web应用程序。

https://learn.jquery.com/jquery-ui/getting-started/ https://learn.jquery.com/jquery-ui/getting-started/

Make sure you include a reference to it before jQuery UI: 确保在jQuery UI之前包含对它的引用:

<head>
    <title></title>
    -- jQuery.js reference here --
    <script type="text/javascript" src="~/Scripts/jquery-ui-1.11.4.min.js"></script>
    <script type="text/javascript" src="~/scripts/moment-with-locales.min.js"></script>

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

相关问题 BootStrap:未捕获的TypeError:$(...)。datetimepicker不是函数 - BootStrap : Uncaught TypeError: $(…).datetimepicker is not a function Wordpress - 未捕获的类型错误:$(…).datetimepicker - Wordpress - Uncaught TypeError: $(…).datetimepicker 已解决 - Uncaught TypeError: $(...).datetimepicker is not a function at app.js:61 - Solved - Uncaught TypeError: $(…).datetimepicker is not a function at app.js:61 Highchart未捕获的错误-Uncaught TypeError:$(…).highcharts不是函数 - Highchart uncaught error - Uncaught TypeError: $(…).highcharts is not a function 未捕获的TypeError:$ .ajax(...)。error不是函数 - Uncaught TypeError: $.ajax(…).error is not a function jQuery 错误:未捕获的类型错误:$ 不是函数 - jQuery Error: Uncaught TypeError: $ is not a function 错误:未捕获的类型错误:未定义不是函数 - Error: Uncaught TypeError: undefined is not a function 未捕获的类型错误:$(...).tooltip 不是函数错误 - Uncaught TypeError: $(...).tooltip is not a function error 未捕获的类型错误:$(...).fullCalendar 不是 function 错误 - Uncaught TypeError: $(…).fullCalendar is not a function error 获取TypeError:$(…).datetimepicker不是一个函数 - Getting TypeError: $(…).datetimepicker is not a function
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM