未捕获的TypeError:$(...)。datepick不是asp.net中jQuery日期时间的函数

时间:2017-07-17 07:35:02

标签: jquery asp.net datepicker

我没有通过jQuery日期时间选择器获取文本框中的日期,而不是我收到错误,即

  

未捕获的TypeError:$(...)。datepick不是函数

在asp.net中

,而相同的代码在HTML中运行良好。我在搜索引擎和Stack Overflow中搜索了很多关于这个错误的东西,但没有任何作用。

这是我的代码

<script src="js/jquery.min.2.1.1.js"></script>
    <script src="js/jquery.plugin.min.js"></script>
    <script src="js/jquery.datepick.js"></script>

    <script>
        $(function () {
            alert();
            $('#birthdate').datepick({ dateFormat: 'dd-mm-yyyy' });
        });
    </script>

<input type="text" id="birthdate"/>

2 个答案:

答案 0 :(得分:0)

在这里,您可以使用小提琴https://jsfiddle.net/gu8n51jz/

&#13;
&#13;
$(function() {
	alert();
	$('#inlineDatepicker').datepick({onSelect: showDate});
});

function showDate(date) {
	alert('The date chosen is ' + date);
}
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-countdown/2.0.2/jquery.plugin.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/datepick/5.1.1/js/jquery.datepick.min.js"></script>

<input type="text" id="inlineDatepicker" />
&#13;
&#13;
&#13;

尝试使用CDN链接而不是本地,然后一旦它开始工作,用本地下载的文件替换CDN链接。

本地代码

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
    <title>jQuery Datepicker</title>
    <link href="css/jquery.datepick.css" rel="stylesheet">
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-countdown/2.0.2/jquery.plugin.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/datepick/5.1.1/js/jquery.datepick.min.js"></script>
    <script>
        $(function() {
            alert();
            $('#inlineDatepicker').datepick({onSelect: showDate});
        });

        function showDate(date) {
            alert('The date chosen is ' + date);
        }
    </script>
</head>
<body>

    <input type="text" id="inlineDatepicker" />

</body>

答案 1 :(得分:0)

如果在添加JQuery和datetimepicker js之后仍然出现错误而不是&#34; RECHECK &#34;代码......您必须在该页面中两次调用其中任何一个JS。

尝试在pagesource中找到...