TypeError: 'undefined' is not a function (evaluating '$(document)')

前端 未结 14 1817
猫巷女王i
猫巷女王i 2020-11-22 07:13
  1. I\'m using a WordPress site.
  2. I\'m including this script in the header.

When the script loads, I get this error:

TypeErro

相关标签:
14条回答
  • 2020-11-22 07:58

    Two things:

    1. Be sure that you have jQuery library added, before your $(document).
    2. Then just change all "$" with: jQuery , as the previous comments.
    0 讨论(0)
  • 2020-11-22 07:59

    Use jQuery's noConflict. It did wonders for me

    var example=jQuery.noConflict();
    example(function(){
    example('div#rift_connect').click(function(){
        example('span#resultado').text("Hello, dude!");
        });
    });
    

    That is, assuming you included jQuery on your HTML

    <script language="javascript" type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
    
    0 讨论(0)
提交回复
热议问题