`$`没有定义。未捕获的参考错误

时间:2017-11-18 21:09:45

标签: javascript jquery html

我是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

不知何故,我无法找到此错误的解决方案。非常感激您的帮忙。感谢您的时间和精力。

1 个答案:

答案 0 :(得分:5)

您需要从脚本代码中删除async,因为这实际上是并行加载和运行这些文件,这意味着您的script.js文件可能在jquery文件均匀之前运行加载。

此外,您不需要加载jQuery的缩小版和非缩小版。只需加载缩小版本。