jquery滚动悬停div的高度

jquery滚动悬停div的高度,jquery,wordpress,Jquery,Wordpress,我有一个wordpress循环。每篇文章都有“.post”类。我有一个按钮,上面写着每一篇文章的“.skip”。单击按钮时,我希望页面滚动到下一个。在循环中发布 我在用这个 $(function(){ $(window).scroll(function(){ $(".post").each(function(){ var height = $(".post").height(); var scroll = $(window)

我有一个wordpress循环。每篇文章都有“.post”类。我有一个按钮,上面写着每一篇文章的“.skip”。单击按钮时,我希望页面滚动到下一个。在循环中发布

我在用这个

$(function(){
    $(window).scroll(function(){
        $(".post").each(function(){
            var height = $(".post").height();
            var scroll = $(window).scrollTop();
            $(".skip").click(function(){
                $(window).scrollTop(scroll+height);
            });
        });
    });
});
有些事情已经做了,但不是它应该做的

我的意思是..该页面在单击时滚动,但与第一个.post的高度相同(无论.post.skip按钮属于什么)

救命啊

wp循环中的.post容器

<article <?php post_class(); ?>>
    <div class="skip">skip</div>
    <?php if ( has_post_thumbnail()) :  ?>
        <div class="container">
            <div>
                <?php the_post_thumbnail(); ?>
            </div>
        <h2 class="post-title"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
        </div>
    <?php else: ?> 
        <h2 class="post-title"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
    <?php endif; ?>
    <?php the_content(); ?>
    <a href="<?php the_permalink(); ?>" class="more">more</a>
</article>

您应该试试这个

$(function(){
    $(window).load(function(){
        $(".post .skip").click(function(){
            var height = $(this).parent(".post").height();
            var scroll = $(window).scrollTop();

            $(window).scrollTop(scroll+height);
        });
    });
});

您无法在单击事件回调之外初始化var“scroll”,但是这将是0(初始顶部滚动:页面顶部=0)。

如果您可以提供HTML标记的示例,这将非常有帮助。添加在主帖子中!)如果无法解决,是否有其他方法来实现我想要的(一个工作的跳过按钮)?你试过我编辑的答案吗?是的。这样效果更好。不过,我还是不高兴!我会试着想出一个不同的办法!谢谢
$(function(){
    $(window).load(function(){
        $(".post .skip").click(function(){
            var height = $(this).parent(".post").height();
            var scroll = $(window).scrollTop();

            $(window).scrollTop(scroll+height);
        });
    });
});