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

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

问题描述

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

Possible Duplicate:
jQuery dollar sign is undefined

我想知道为什么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 $().

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

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