没有错误,但 jQuery 代码不起作用
有人能说一下这是怎么回事吗?首先,我加载了 jQuery Waypoints (http://imakewebthings.github.com/jquery-waypoints/< /a>) 然后包含您可以在文本后面看到的代码。 向下滚动页面时,我需要对图像进行淡入淡出效果,但什么也没发生。我在 Stack Overflow 上找到了这个解决方案 - JQuery当用户滚动到该 div 时淡入该 div 这是我尝试执行解决方案的链接 - http://layot.prestatrend.com 谢谢!
// by default your element will be hidden
$('.ajax_block_product').hide();
// call waypoint plugin
$('.ajax_block_product').waypoint(function(event, direction) {
// do your fade in here
$(this).fadeIn();
}, {
offset: function() {
// The bottom of the element is in view
return $.waypoints('viewportHeight') - $(this).outerHeight();
}
});
Could someone say what the matter is? At first I have load jQuery Waypoints (http://imakewebthings.github.com/jquery-waypoints/) then included the code you could see after the text.
I need fadeIn effect on images when scrolling down the page but nothing heppen at all. I found this solution here at Stack Overflow - JQuery fade-in a div when user scrolls to that div
And here is the link where I am trying to do my solution - http://layot.prestatrend.com
Thanks!
// by default your element will be hidden
$('.ajax_block_product').hide();
// call waypoint plugin
$('.ajax_block_product').waypoint(function(event, direction) {
// do your fade in here
$(this).fadeIn();
}, {
offset: function() {
// The bottom of the element is in view
return $.waypoints('viewportHeight') - $(this).outerHeight();
}
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
jQuery hide 函数在元素上设置
display:none
。具有display:none
的元素不会报告正确的偏移
。尝试最初将不透明度设置为 0 或将可见性设置为隐藏。The jQuery hide function sets
display:none
on an element. Elements withdisplay:none
don't report the correctoffset
. Try initially setting the opacity to 0 or visibility to hidden instead.