1. 程式人生 > >JQuery點選事件回到頁面頂部效果

JQuery點選事件回到頁面頂部效果

//2個div,點選某個時回到頂部

<div style="height:1000px">111111111111111</div>
 <div id="top" >top</div>

<引用JQuery>

<script type="text/javascript">

$(function(){
  $("#top").click(function() {
      $("html,body").animate({scrollTop:0}, 500);
  }); 
 })

</script>