2016-07-22 7 views
0

私は見て、SOから多くのソリューションを実装しようとしましたが、動作させることはできません。私はiscrollライブラリを使用してタイムアウトなどを設定しようとしました。ページのトップへページのトップへモバイルでは動作しません

ユーザーがボタンをクリックしたときに、携帯電話デバイスのウィンドウ/ページの上部にスクロールします。あなたが文書ですべての作業をされているバージョンを持ってここに

$('.box').click(function(){ 
    document.body.scrollTop = 0; 
}); 

答えて

0

;)

// ===== Scroll to Top ==== 
$(window).scroll(function() //When the page is being scrolled 
{ 
    if ($(this).scrollTop() >= 150) // If page is scrolled more than 150px 
    { 
     $("#return_to_top").fadeIn(200); // Fade in the arrow, 200 means that arrow will be shown in 200 miliseconds (fast) - 600 means slow, 400 is normal 
    } 
    else 
    { 
     $("#return_to_top").fadeOut(200); // Else fade out the arrow, fast 
    } 
}); 

$(document).ready(function() //When the page is ready, load function 
{ 
    $("#return_to_top").click(function() // When arrow is clicked 
    { 
     $("body,html").animate(
     { 
      scrollTop : 0      // Scroll to top of body 
     }, 400); //how fast the scrolling animation will be in miliseconds 
    }); 
}); 
関連する問題