How to make text appear on scroll in html

前端 未结 5 2014

Hello, I want a certain text to appear when I scroll past it or when I scroll until the point where the text is. The effect when appearing should be somewhat like the first effe

5条回答
  •  深忆病人
    2021-02-02 18:31

    var div=$("#divtochange");
    $(window).scroll(function () {
                var windowpos = $(window).scrollTop();
                //---check the console to acurately see what the positions you need---
                console.log(windowpos);
                //---------------------
    
    //Enter the band you want the div to be displayed
                if ((windowpos >= 0) && (windowpos <= 114)){ 
                    div.addClass("AfterScroll");
                }
                else{
                    div.removeClass("AfterScroll");
                }
    

提交回复
热议问题