Aar*_*her 11 html php ajax jquery
无论如何,我可以做到这一点,所以页面将在内容加载后自动滚动到顶部(通过Ajax)?
这是我显示内容的代码:
$(document).ready(function () {
var my_layout = $('#container').layout();
$("a.item_link").click(function () {
$("#loader").fadeIn();
feed_url = $(this).attr("href");
$.ajax({
type: "POST",
data: "URL=" + feed_url,
url: "view.php",
success: function (msg) {
$("#view-area").html(msg);
$("#loader").fadeOut();
}
});
return false;
});
});
Run Code Online (Sandbox Code Playgroud)
所以在'view-area'加载了它的内容后,我可以让页面自动滚动到顶部吗?
Jus*_*ony 25
只需使用滚动功能
scrollTo(0);
Run Code Online (Sandbox Code Playgroud)
如果你想要jquery,那么这里有一个平滑的好例子 :)
从链接:
$('html, body').animate({ scrollTop: 0 }, 0);
//nice and slow :)
$('html, body').animate({ scrollTop: 0 }, 'slow');
Run Code Online (Sandbox Code Playgroud)
把它放在你的代码中
...
success: function (msg) {
$("#view-area").html(msg);
$("#loader").fadeOut();
//Put code here like so
$('html, body').animate({ scrollTop: 0 }, 0);
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
25103 次 |
最近记录: |