没有错误,但jQuery代码不起作用

时间:2012-02-05 20:24:30

标签: jquery jquery-waypoints

有人能说出来是什么问题吗?起初我加载了jQuery Waypoints(http://imakewebthings.github.com/jquery-waypoints/),然后包含了你在文本后可以看到的代码。 向下滚动页面时我需要淡入淡出效果,但根本没有任何问题。我在Stack Overflow找到了这个解决方案 - JQuery fade-in a div when user scrolls to that 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();
    }
});

1 个答案:

答案 0 :(得分:0)

jQuery hide函数在元素上设置display:nonedisplay:none的元素无法报告正确的offset。首先尝试将不透明度设置为0,或将可见性设置为隐藏。