下面的代码工作正常,但我想改进该功能,因为它在 div 加载时滞后。我在页面中间有一个菜单,内容仅在我单击菜单时才会出现,将菜单向右滚动到顶部并在#showContent div中加载外部内容。
$(document).ready(function() {
$('a[href^="#"]').click(function(){
var target = $(this).attr("href");
$('html, body').animate({ scrollTop: $(target).offset().top}, 2000);
return false;
})
});
$(document).ready(function() {
window.onload = init;
function init(){
$("#quemsomos").click(function(){
$("#show_content").load("quem_somos.php");
});
$("#websites").click(function(){
$("#show_content").load("websites.php");
});
$("#clientes").click(function(){
$("#show_content").load("clientes.php");
});
$("#fotos").click(function(){
$("#show_content").load("fotos.php");
});
}
});
提前致谢。