Uncaught TypeError: undefined is not a function on loading jquery-min.js

前端 未结 13 736
北荒
北荒 2020-11-28 22:55

I\'m building a normal webpage which requires me to load about five CSS files and ten Javascript files.

  • When loading them separately in the HTML page, my webpa
相关标签:
13条回答
  • 2020-11-28 23:24

    I got the same error from having two references to different versions of jQuery.

    In my master page:

    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
    

    And also on the page:

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"> </script>
    
    0 讨论(0)
  • 2020-11-28 23:24

    I've run into the very same issue, when mistakenly named variable with the very same name, as function.

    So this:

    isLive = isLive(data);
    

    failed, generating OP's mentioned error message.

    Fix to this was as simple as changing above line to:

    isItALive = isLive(data);
    

    I don't know, how much does it helps in this situation, but I decided to put this answer for others looking for a solution for similar problems.

    0 讨论(0)
  • 2020-11-28 23:24

    Yes, i also I fixed it changing in the js libraries to the unminified.

    For example, in the tag, change:

    <script type="text/javascript" src="js/jquery.ui.core.min.js"></script>
    <script type="text/javascript" src="js/jquery.ui.widget.min.js"></script>
    <script type="text/javascript" src="js/jquery.ui.rcarousel.min.js"></script>
    

    For:

    <script type="text/javascript" src="js/jquery.ui.core.js"></script>
    <script type="text/javascript" src="js/jquery.ui.widget.js"></script>
    <script type="text/javascript" src="js/jquery.ui.rcarousel.js"></script>
    

    Quiting the 'min' as unminified.

    Thanks for the idea.

    0 讨论(0)
  • 2020-11-28 23:30

    In case there are any morons out there like me, I had this frustrating problem because I forgot a simple

    new

    keyword before instantiating a new object.

    0 讨论(0)
  • 2020-11-28 23:34

    This solution worked for me

    
        ;(function($){
            // your code
        })(jQuery);
    
    

    Move your code inside the closure and use $ instead of jQuery

    I found the above solution in https://magento.stackexchange.com/questions/33348/uncaught-typeerror-undefined-is-not-a-function-when-using-a-jquery-plugin-in-ma

    after seraching too much

    0 讨论(0)
  • 2020-11-28 23:34

    For those out there who still couldn't fix this, I did so by changing my 'this' to '$(this)' when using jQuery.

    E.G:

    $('.icon').click(function() {
        this.fadeOut();
    });
    

    Fixed:

    $('.icon').click(function() {
        $(this).fadeOut();
    });
    
    0 讨论(0)
提交回复
热议问题