windk

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>

  


posted on 2011-09-08 13:34  windk  阅读(589)  评论(0)    收藏  举报

导航