2013-11-15 121 views
0

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> 

回答