2014-07-03 81 views
0

Muiltiple滾動錯誤我有以下的HTML頁面在HTML頁面

<html> 
    <head> 
     <title> Test Page </title> 

    </head> 

    <body> 
      <div id="testdiv" style="height:300px; width:200px; overflow:scroll;"> 
       This is a sample div    This is a sample div    This is a sample div    This is a sample div    This is a sample div    This is a sample div    This is a sample div    This is a sample div    This is a sample div    This is a sample div    This is a sample div    This is a sample div    This is a sample div    This is a sample div    This is a sample div    This is a sample div    This is a sample div    This is a sample div    This is a sample div    This is a sample div    This is a sample div    This is a sample div    This is a sample div    This is a sample div    This is a sample div    This is a sample div    This is a sample div    This is a sample div    This is a sample div    This is a sample div 

       <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/> 
      </div> 
      <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/> 
    </body> 

</html> 

我這個頁面我添加了下面的腳本

<script> 
$(window).scroll(function(){ 
    alert('Window Scroll'); 
}); 

$('#testdiv').scroll(function(){ 
    alert('testdiv Scroll'); 
}); 

</script> 

這將提醒我哪些滾動動作被調用。

如果我的身體滾動它提醒我,Window Scroll

,如果我在一個div這是人體的提醒我爲testdiv scroll裏面滾動,Window Scroll

,但應警惕僅testdiv scroll爲什麼它的警報我2個滾動事件

+0

在我的FF 30上,我沒有這個錯誤。 – Portekoi

回答

3

試試這個

$('#testdiv').scroll(function(e){ 
    alert('testdiv Scroll'); 
    e.stopPropagation(); 
});