为什么我会得到“$ 未定义"?使用 jQuery 插件后? [英] Why do I get "$ is undefined" after using jQuery plugin?

查看:21
本文介绍了为什么我会得到“$ 未定义"?使用 jQuery 插件后?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
jQuery 美元符号未定义

我想知道 TypeError: $ is undefined 为什么会出现错误,我知道替代方法是使用 jQuery 来解决问题,为什么 $ 是未定义的,即使使用了正确的 jQuery 插件.

I want to known Why does TypeError: $ is undefined Error Occurs , I known the alternative is to use jQuery which solves the problem, why does $ is undefined, even after using correct jQuery plugin.

谁能给我关于这个的解释,我知道要使用的替代方案以及为什么该替代方案有效.谁能给我解释一下.

Can any one Give me the Explanation regarding this , I known the alternative to be used and also why that alternative works . can any one Explain Me Please.

推荐答案

如果你的意图是在调用 $() 时使用 jQuery 库,那么 $是一个通常由 jQuery 库在加载时定义的函数.如果您尝试使用该符号时未定义该符号,则有以下可能性:

If your intent is to be using the jQuery library when you call $(), then $ is a function normally defined by the jQuery library when it loads. If that symbol is not defined when you try to use it, then there are these possibilities:

  1. 您尚未将 jQuery 库加载到出现此错误的页面中.
  2. 您试图在加载 jQuery 之前引用 $ 函数,在这种情况下,您需要将 jQuery 库移到页面的前面,或者将有问题的代码移到加载 jQuery 的位置之后.
  3. 一些 jQuery 代码调用了 jQuery.noConflict() 导致 $ 符号未定义.在这种情况下,使用 jQuery() 代替 $() 会起作用.
  1. You haven't loaded the jQuery library into the page where you're getting this error.
  2. You are trying to reference the $ function before jQuery is loaded in which case you would either need to move the jQuery library earlier in your page or move the offending code after where jQuery is loaded.
  3. Some jQuery code has called jQuery.noConflict() which causes the $ symbol to be undefined. In this case, using jQuery() will work instead of $().

这篇关于为什么我会得到“$ 未定义"?使用 jQuery 插件后?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆