我是JavaScript和JQuery的新手。我正面临这个问题,浏览器检测到$
未定义。我已经看到了很多解决这个问题的方法。但事实证明他们都不适合我。在我的HTML中,我在调用脚本之前从本地目录加载jquery库。
Directory that contains the jquery library and the script
HTML header where I'm loading the scripts
DOM error that the browser shows me every time I load the page
不知何故,我无法找到此错误的解决方案。非常感激您的帮忙。感谢您的时间和精力。
答案 0 :(得分:5)
您需要从脚本代码中删除async
,因为这实际上是并行加载和运行这些文件,这意味着您的script.js
文件可能在jquery
文件均匀之前运行加载。
此外,您不需要加载jQuery的缩小版和非缩小版。只需加载缩小版本。