Javascript 未捕获的类型错误:$(...).tabs 不是函数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31179722/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Uncaught TypeError: $(...).tabs is not a function
提问by Ibrahim Amer
I think there is a strange problem with jquery I got this exception when page load here is my markup :
我认为 jquery 有一个奇怪的问题,当页面加载这里是我的标记时,我得到了这个异常:
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<link href="../Layouts/en-us/css/custom.css" rel="stylesheet" />
<link href="../Layouts/en-us/css/jquery-ui.css" rel="stylesheet" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="../ckeditor/ckeditor.js"></script>
<script src="../ckeditor/adapters/jquery.js"></script>
<script src="/Layouts/en-us/js/jquery-ui.min.js"></script>
</asp:Content>
here is the function that causes error
这是导致错误的函数
$(function () {
$("#tabs").tabs();
if ($("#ListBoxPages").val() == null) {
$("#tabs").css("display", "none");
}
$("#ListBoxPages").change(function () {
$("#tabs").css("display", "block");
});
});
All relative paths to Layouts and jquery were copied from another markup which works pretty fine with no error
Layouts 和 jquery 的所有相对路径都是从另一个标记复制的,这个标记工作得很好,没有错误
回答by Shirish
I can see that you are loading jquery twice so try to remove that
我可以看到您正在加载 jquery 两次,因此请尝试将其删除
<script src="/Layouts/en-us/js/jquery-ui.min.js" />
<script src="/Layouts/en-us/js/jquery-ui.min.js" />
and keep only -
并且只保留——
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" />
then use below code in place of your function (First check by changes in this function then try with removing that jquery-ui.min.js)
然后使用下面的代码代替您的函数(首先检查此函数中的更改,然后尝试删除该 jquery-ui.min.js)
$( document ).ready(function() {
$("#tabs").tabs();
if ($("#ListBoxPages").val() == null) {
$("#tabs").css("display", "none");
}
$("#ListBoxPages").change(function () {
$("#tabs").css("display", "block");
});
});
回答by Basit
$("#tabs").tabs(); requires Jquery.UI just include
$("#tabs").tabs(); 需要 Jquery.UI 只包括
<script src="/Layouts/en-us/js/jquery-ui.min.js" />
or use CDN
或使用 CDN
<scriptsrc="https://code.jquery.com/ui/1.12.1/jquery-ui.js"integrity="sha256-T0Vest3yCU7pafRw9r+settMBX6JkKN06dqBnpQ8d30="crossorigin="anonymous"></script>