[英]Uncaught TypeError: Cannot set property 'followTo' of undefined
I'm trying to adapt this fiddle: http://jsfiddle.net/Tgm6Y/1/ 我正在尝试适应这种提琴: http : //jsfiddle.net/Tgm6Y/1/
var windw = this;
$.fn.followTo = function ( pos ) {
var $this = this,
$window = $(windw);
$window.scroll(function(e){
if ($window.scrollTop() > pos) {
$this.css({
position: 'absolute',
top: pos
});
} else {
$this.css({
position: 'fixed',
top: 0
});
}
});
};
$('#product_right').followTo(250);
to my website: http://www.victoriarockera.com/shop/ropa-chica/soy-yo-979.html 到我的网站: http : //www.victoriarockera.com/shop/ropa-chica/soy-yo-979.html
but for any reason, I'm receiving this error: 但由于任何原因,我收到此错误:
Uncaught TypeError: Cannot set property 'followTo' of undefined
未捕获的TypeError:无法设置未定义的属性'followTo'
and it is not working... 而且不起作用...
why? 为什么?
Thanks 谢谢
I think the problem is that ('#product_right').followTo(250);
我认为问题是
('#product_right').followTo(250);
is not triggered within your website. 未在您的网站内触发。 Try to add the following code to your site:
尝试将以下代码添加到您的站点:
$( document ).ready(function() {
('#product_right').followTo(250);
});
That could also explain why it works within JSFiddle and not on your website. 这也可以解释为什么它在JSFiddle中而不是在您的网站上有效。 You might try that.
您可以尝试一下。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.