【发布时间】:2013-05-23 14:15:21
【问题描述】:
jQuery(document).ready(function(){
jQuery(window).scroll(function(){
if (jQuery(this).scrollTop() > 600) {
jQuery('.scrollup').fadeIn();
} else {
jQuery('.scrollup').fadeOut();
}
if(jQuery(this).scrollTop() < 600) {
jQuery('.scrolldown').fadeIn();
}else {
jQuery('.scrolldown').fadeOut();
}
});
jQuery('.scrollup').click(function(){
jQuery("html, body").animate({ scrollTop: 0 }, 900);
return false;
});
jQuery('.scrolldown').click(function() {
jQuery("html, body").animate({ scrollTop: jQuery(document).height()-jQuery(window).height() }, 900);
return false;
});
});
我在 Wordpress 网站上为页面滚动器尝试了此代码。当我从本地主机运行而不是在实时站点上运行时,它可以工作。为什么它不能在实时网站上运行?
我在 Javascript 控制台(通过 Firebug)上收到此错误:
TypeError: invalid 'in' operand e
[Break On This Error]
...pe);return e}x.each({parent:function(e){var t=e.parentNode;return t&&11!==t.node...
jquery.min.js (line 5)
TypeError: invalid 'in' operand e
[Break On This Error]
...pe);return e}x.each({parent:function(e){var t=e.parentNode;return t&&11!==t.node...
jquery.min.js (line 5)
TypeError: invalid 'in' operand e
[Break On This Error]
...pe);return e}x.each({parent:function(e){var t=e.parentNode;return t&&11!==t.node...
jquery.min.js (line 5)
TypeError: invalid 'in' operand e
[Break On This Error]
...pe);return e}x.each({parent:function(e){var t=e.parentNode;return t&&11!==t.node...
jquery.min.js (line 5)
TypeError: invalid 'in' operand e
[Break On This Error]
...pe);return e}x.each({parent:function(e){var t=e.parentNode;return t&&11!==t.node...
jquery.min.js (line 5)
TypeError: invalid 'in' operand e
[Break On This Error]
...pe);return e}x.each({parent:function(e){var t=e.parentNode;return t&&11!==t.node...
jquery.min.js (line 5)
TypeError: invalid 'in' operand e
[Break On This Error]
...pe);return e}x.each({parent:function(e){var t=e.parentNode;return t&&11!==t.node...
【问题讨论】:
-
你是在导入jQuery,并且在上述代码出现在文档中之前就这样做了吗?浏览器控制台有错误吗?
-
我将 与上述脚本和我也得到了错误
-
Vicky,请将错误添加到您的帖子中并将其从 cmets 中删除。在 cmets 中阅读太难了
-
嗯...除了上面列出的内容之外,您是否还在实时站点上进行任何其他 jQuery 操作?特别是涉及 jquery.parseJSON() 的任何事情?
-
看起来您正在页面上同时加载 MooTools 和 jQuery。我不确定,但我猜这两个库之间存在冲突。
标签: javascript jquery jquery-plugins wordpress