【发布时间】:2014-05-08 10:33:17
【问题描述】:
我在 Wordpress 中创建了一个作品集,其中的帖子直接在同一页面上打开。一直很困难,但我设法 - following these steps - 让一切正常......或几乎。
我现在想要确保当用户点击一个元素时,页面滚动到顶部以查看产品详细信息。我尝试了各种方法都没有成功:(
这是网站:http://www.grafichepioppi.it/category/portfolio/
这是我的代码:
$(document).ready(function(){
$.ajaxSetup({
cache:true,
async: true,
complete:function(){
$('body,html').animate({scrollTop: 0}, 800);
}});
$("a.link-portfolio").click(function(){
var post_url = $(this).attr("href");
var post_id = $(this).attr("rel");
$("#portfolio-featured").html("<div class='loading-ajax'></div>").fadeIn(500);
$("#portfolio-featured").load(post_url, function() {
$('.portfolio-featured').show( 4000 );
});
window.location.hash = post_id;
return false;
});
});
关于如何做到这一点的任何想法?
【问题讨论】:
-
嗯...然后将
$('body,html').animate({scrollTop: 0}, 800);从$.ajaxSetup({...})移动到$("a.link-portfolio").click(..) -
我试过了,还是不行。 Chrome的控制台没有错误,我不知道错误在哪里
标签: jquery ajax wordpress scroll