Uncaught TypeError: undefined is not a function in datepicker

匿名 (未验证) 提交于 2019-12-03 00:56:02

问题:

I am trying to use date picker of jquery in mvc4.

It was giving me error:

Uncaught TypeError: undefined is not a function 

My jQuery function is like:

$(document).ready(function () {     $('#dpFrom').datepicker(); }); 

html part is like:

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

I refered :

Uncaught TypeError: undefined is not a function while using jQuery UI

And included :

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css" /> <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script> 

So total javascript became:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css" /> <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>   <script type="text/javascript">     jQuery(document).ready(function () {         jQuery('#dpFrom').datepicker();      }); </script> 

Still its giving me error.

Please help...

回答1:

I think that you have a duplicate jQuery reference. Could you open a "View Source" on your web browser and enumerate your jQuery references? It is a common error and easily missed. Maybe a bundle definition or your layout and content pages have the same reference.



回答2:

The path should be https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js not //ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js in both referencing script and css tags



回答3:

<script type="text/javascript">     $( "#datepicker" ).datepicker();       </script> 

I tried this one, when i erase the function().



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!