0
点赞
收藏
分享

微信扫一扫

JQ的自定义事件操作

zmhc 2022-07-27 阅读 52


设置一个滚轮事件放到缩小图片

<body>
<img src="1.jpg" id="img1">
</body>

<script>function(){  
$('#img1').on('zoomIn',function(){ //缩小
$(this).css('width',200);
});

$('#img1').on('zoomOut',function(){ //放大
$(this).css('width',700);
});

$('#img1').on('DOMMouseScroll',function(ev){

if(ev.originalEvent.detail > 0){
$(this).trigger('zoomIn');
}
else{
$(this).trigger('zoomOut');
}
});
});
</script>


举报

相关推荐

0 条评论