2014-09-26 34 views
0

喜的朋友我只想得到窗口scrollTop()與下文提到的功能,但它不工作我不知道爲什麼window.scroll jQuery的不工作

請檢查fiddle Here,也可以低於

校驗碼SCRIPT

$(document).ready(function(e) { 
$(window).scroll(function(){ 
    var top = $(this).scrollTop(); 
    }); 

)} 
+0

其工作http://jsfiddle.net/sdcoxL6h/1/ – 2014-09-26 08:29:19

回答

0

HTML

<p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p><p>s</p> 

<input type="button" value="top" name="top" id="btnTop">  

的jQuery:

$('#btnTop').on("click",function(){ 
$('html,body').animate({ scrollTop: 0 }, 'slow', function() { 
         alert("reached top"); 
        }); 
}); 

更新時間:http://jsfiddle.net/sdcoxL6h/4/