我在iframe中有以下jQuery代码:
<script>
jQuery("#logBtn").click(function(){
jQuery("#content-promo").load("/path/to/file.php", function(response, status, xhr) {
if (status == "error") {
var msg = "Sorry but there was an error: ";
$("#error").html(msg + xhr.status + " " + xhr.statusText);
}else{ //update
$("html, body").animate({ scrollTop: 0 }, "slow");
}
});
return false;
});
</script>
在 AJAX 请求之后,iframe 如何滚动回顶部?