单击“Prew”和“Next”按钮链接后页面保持向下滚动

时间:2014-02-19 15:44:53

标签: jquery wordpress

我希望页面在我的类别单页面中单击“Prew”和“Next”按钮后保持向下滚动。而不是“跳”到顶部(重新加载)......

屏幕截图,http://awesomescreenshot.com/0042dlfk41

网址测试页面http://planeta.se/bullerWebb/nyheter/nattrea/

jQuery(document).ready(function(){
    // ajax pagination
    jQuery('.navBottom a').live('click', function(){ // if not using wp-page-numbers, change this to correct ID
        var link = jQuery(this).attr('href');
                    // #main is the ID of the outer div wrapping your posts
        jQuery('.prodWrapper1').html('');
                    // #entries is the ID of the inner div wrapping your posts
        jQuery('.prodWrapper1').load(link+' #entries')

    });
}); // end ready function
        </script>
HTML
    <div id="nav-above" class="navigation">
                        <div class="nav-previous"><?php previous_post_link('&laquo; %link', 'Prew', TRUE); ?></div>
                        <div class="nav-next"><?php next_post_link('%link &raquo; ', 'Next', TRUE); ?></div>
                    </div><!-- #nav-above -->

1 个答案:

答案 0 :(得分:0)

编辑:没看到你已经使用了href,传递了事件,preventDefault()将是你最好的选择。

jQuery(document).ready(function(){

    // ajax pagination
    jQuery('.navBottom a').on('click', function(event){ // if not using wp-page-numbers, change this to correct ID
        event.preventDefault();
        var link = jQuery(this).attr('href');
                    // #main is the ID of the outer div wrapping your posts
        jQuery('.prodWrapper1').html('');
                    // #entries is the ID of the inner div wrapping your posts
        jQuery('.prodWrapper1').load(link+' #entries');

    });
}); // end ready function