本文介绍了jQuery的问题:.datepicker不是函数吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
要求是单击文本框时使用jquery datepicker.添加了所有js引用,但仍然出现.datepicker不是函数错误.代码如下.我错过了什么吗?
The requirement is to use jquery datepicker when textbox is clicked. All the js references is added but still .datepicker is not a function error comes up. The code is given below. Am i missing out on something?
错误详细信息
Uncaught TypeError: $(...).datepicker is not a function
at HTMLDocument.<anonymous> (Index:56)
at c (jquery-1.10.2.min.js:21)
at Object.fireWith [as resolveWith] (jquery-1.10.2.min.js:21)
at Function.ready (jquery-1.10.2.min.js:21)
at HTMLDocument.q (jquery-1.10.2.min.js:21)
代码:
@{
ViewBag.Title = "Index";
}
<!-- Include Date Range Picker -->
<link rel="stylesheet" href="../../Content/bootstrap-datepicker.css" />
<script type="text/javascript" src="../../Scripts/jquery-1.10.2.min.js"> </script>
<script type="text/javascript" src="../../Scripts/jquery-ui-1.10.0.min.js"></script>
<script>
$(document).ready(function() {
$(".datepicker").datepicker({ format: 'dd/mm/yyyy', autoclose: true, todayBtn: 'linked' });
});
</script>
<h3>BootStrap Datetime Picker Example</h3>
<hr />
<div>Click textbox to open datetime picker: <input type="text" id="fromDate" class="datepicker" /></div>
<script type="text/javascript" src="../../Scripts/jquery.datetimepicker.js"> </script>
推荐答案
在页面加载jjquery-ui.css,jquery-1.12.4.js和query-ui.js之前,您正在加载datepicker.js.将其放在它们下面,否则它将无法扩展其功能.
You're loading datepicker.js before the page has loaded jjquery-ui.css, jquery-1.12.4.js and query-ui.js. Place it below them, otherwise it can't extend their functionality.
这篇关于jQuery的问题:.datepicker不是函数吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!