<div class="page">
div content
</div>
<script>
if( scroll mouse up while hovering #page )
$('.page').animate({'left':'+40px'});
if( scroll mouse down while hovering #page )
$('.page').animate({'left':'-40px'});
</script>
我想做一些类似上面例子的事情。有人可以帮助我吗?
最佳答案
您可以使用 this mousewheel plugin然后:
$('.page').mousewheel(function(event, delta) {
event.preventDefault(); // if you want to prevent the window from scrolling
$(this).animate({left: (delta>0 ? '+' : '-')+'40px'});
});
关于javascript - 在div上使用鼠标滚动来触发动画?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9145457/