gpt4 book ai didi

javascript - jQuery 修复 "Uncaught TypeError: $ is not a function"错误

转载 作者:行者123 更新时间:2023-11-28 04:17:15 25 4
gpt4 key购买 nike

我的代码:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>      
<script src="http://someothersite.com/external.js"></script>

外部.js:

$("head").append(unescape(""));

不幸的是,当我包含外部脚本时,我收到以下错误:

Uncaught TypeError: $ is not a function

我该如何解决这个问题?请记住,我无法编辑外部 Javascript 文件,因为它是第三方的。

最佳答案

在 JS 文件中使用以下语句。

jQuery(document).ready(function($){

// jQuery code is in here

});

声明上述语句后,您将可以使用 $ 符号。

关于javascript - jQuery 修复 "Uncaught TypeError: $ is not a function"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45723642/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com