如何向右滚动,并通过鼠标滚轮键左
问题描述:
jsfiddle example1 example2如何向右滚动,并通过鼠标滚轮键左
我的div文字里面, 我想,当用户将扭转鼠标的滚动按钮,所有的div将滑向左或向右 insted top and down,
我尝试写一些代码,我不知道如何从这里继续。 非常感谢您的任何帮助。
这是我的代码。
javascript代码:
var valueToScroll = 0;
$('#divScroll').bind('mousewheel', function(e){
if(e.originalEvent.wheelDelta /120 > 0) {
$(this).scrollLeft(++valueToScroll);
}
else{
$(this).scrollRight(--valueToScroll);
}
});
CSS代码:
div{
width:2000px;
height:100px;
background:red;
}
的html代码:
<div id="divScroll">There is a substantial disparity of 13-17% between the earnings of men and women in the same positions and at similar skill levels, according to a new study by the National Insurance Institute, seeking to examine the socio-economic status of women in Israel between in the years 1997-2011.
</div>
答
使用
document.body.doScroll(event.wheelDelta>0?"left":"right");