首页 新随笔 联系 订阅 管理 个人网站

鼠标滚轮放大缩小

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>练习1</title>
</head>
<style>
*{margin:0px;padding:0px;}
div{
width: 200px;
height: 200px;
margin: 0 auto;
margin-top: 99px;
background-color:#f60;
}
</style>
<script src="jquery-1.11.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
  $(function(){
  $('div').on('zoomOut',function(){  //放大
  $(this).stop().animate({width:"+=66px",height:"+=66px"},1000);
  });
  $('div').on('zoomIn',function(){     //缩小
  $(this).stop().animate({width:"+=-66px",height:"+=-66px"},1000);
  });
  $('div').on('DOMMouseScroll',function(ev){
  //alert(ev.originalEvent.detail)
  if(ev.originalEvent.detail < 0){
   
   $('div').trigger('zoomOut');
  }else if(ev.originalEvent.detail > 0){
  $('div').trigger('zoomIn');
  }
  });
  })
</script>
<body>
<div></div>
</body>
</html>
posted @ 2015-01-06 22:13  __不粘锅  阅读(426)  评论(0编辑  收藏  举报