首页javascriptmousejQuery Event - 如何句柄窗口加载动作事件...

jQuery Event - 如何句柄窗口加载动作事件...

我们想知道如何句柄窗口加载动作事件。...

<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.6.4.js'></script>
<style type='text/css'>
div {
  width: 200px;
  height: 200px;
  background: grey;
  overflow: scroll;
}

div span {
  width: 200px;
  height: 1000px;
  display: block;
}

a {
  cursor: pointer;
}
</style>
<script type='text/javascript'>
$(window).load(function(){
    $('#up').click(function() {
        $('div').stop().animate({scrollTop: '-=100'}, 300); 
    });
    $('#down').click(function() {
        $('div').stop().animate({scrollTop: '+=100'}, 300); 
    });
});
</script>
</head>
<body>
  <div>
    <span></span>
  </div>
  <a id="up">up</a>
  <a id="down"> down</a>
</body>
</html>