scrolleventjavascript3

 <html>

    <head>
<title>facebook.com</title>
    </head>
    <style>
        div{
            background-colorgreen;
            width200px;
            height200px;
            displaynone;
           positionfixed;
           bottom0px;
           right0px;

        }
        body{
            height2000px;
        }
    </style>
    <body>
       <div id='a'>

       </div>
       <script>
           window.addEventListener('scroll',function(e){
               if(window.pageYOffset>150)//scrolling down
               {
                   document.getElementById('a').style.display="block";
               }
               
               else//scrolling up
               {
                document.getElementById('a').style.display="none";
               }
           
           })
           </script>
    </body>
</html>

Comments

Popular posts from this blog

interview questions js[ Anurag Singh ProCodrr]

reactnative_creation