简体   繁体   中英

Uncaught TypeError: $(…).tabs is not a function

I think there is a strange problem with jquery I got this exception when page load here is my markup :

<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

I can see that you are loading jquery twice so try to remove that

<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)

$( document ).ready(function() {
        $("#tabs").tabs();
        if ($("#ListBoxPages").val() == null) {
            $("#tabs").css("display", "none");
        }
        $("#ListBoxPages").change(function () {
            $("#tabs").css("display", "block");
        });
});

$("#tabs").tabs(); requires Jquery.UI just include

<script src="/Layouts/en-us/js/jquery-ui.min.js" />

or use CDN

<scriptsrc="https://code.jquery.com/ui/1.12.1/jquery-ui.js"integrity="sha256-T0Vest3yCU7pafRw9r+settMBX6JkKN06dqBnpQ8d30="crossorigin="anonymous"></script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM