Scroll to top JavaScript in HTML Website

后端 未结 4 1855
故里飘歌
故里飘歌 2021-01-26 13:17

I am trying to implement the scroll to top feature in my website: www.arrow-tvseries.com.

The \"button\" is seen on the website however it does not work properly, becaus

4条回答
  •  春和景丽
    2021-01-26 14:00

    The problem is that your javascript file is actually written in HTML.

    In your HTML head section, you should have:

    
    
    

    Then your back_to_top.js should contain only the following:

    $(function() {
        $(window).scroll(function() {
            if($(this).scrollTop() != 200) {
                $('#backtotop').fadeIn();
            } else {
                $('#backtotop').fadeOut();
            }
        });
    
        $('#backtotop').click(function() {
            $('body,html').animate({scrollTop:0},800);
        });
    });
    

提交回复
热议问题