jquery, 点击页面元素,使其移动到浏览器顶部,再点击还原。
<script>
$(function(){
//save the position top of browser's scroll
prevous = 0;
$(".details").toggle(
function(){
$(".details").next().hide();
$(this).next().show(300);
prevous = $(this).offset().top;
window.scrollTo(10, $(this).position().top);
},
function(){
$(this).next().hide(300);
window.scrollTo(10, prevous-300);
});
//click the content to hide
$(".details").next().click(function(){
$(this).hide(50);
window.scrollTo(10, prevous-300);
});
})
</script>
浙公网安备 33010602011771号