存在类,但出现jquery错误:TypeError $(...)为null [英] Class exists but jquery errors: TypeError $(...) is null
问题描述
在网站http://yn1nll的底部,有一个名为"Inloggen"的按钮.当您单击它时,将显示一个名为"userdata"的div.出于某种神秘的原因,什么也没发生.
At the bottom of the website http://yn1[dot]nl there is a button called "Inloggen". When you click on it a div called "userdata" should show up. For some mysterious reason nothing happens.
Firebug说:
TypeError: $(...) is null
Line: 46
该行包括:
$(".userdata").toggle("4000", function() { });
这有什么问题? div
存在并且具有类名"userdata".
What is wrong about that? The div
exists and has the class name "userdata".
推荐答案
错误消息很明显:$(...)
返回null
.这意味着$
全局变量不能等于jQuery
,因为jQuery
永远不会返回null
(无论所讨论的div是否存在).
The error message is clear: $(...)
returns null
. That means the $
global variable cannot be equal to jQuery
, because jQuery
would never return null
(regardless of whether the div in question exists or not).
实际上,您的代码包含一个调用 jQuery.noConflict
的无冲突脚本,该脚本放弃对$
变量的控制.
Indeed, your code includes a no-conflict script that calls jQuery.noConflict
, which relinquishes control of the $
variable.
解决方案:要么删除无冲突脚本(这可能会破坏其他事情,我不知道),要么编写jQuery
而不是$
.
Solution: either remove the no-conflict script (which might break other things, I have no idea) or else write jQuery
instead of $
.
这篇关于存在类,但出现jquery错误:TypeError $(...)为null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!