div 페이지 스크롤 따르기

2657 단어 div
$(document).ready(function(){

         var timer;

         $(window).scroll(function (){  

                clearInterval(timer);  

                var topScroll=getScroll();  

                var topDiv="100px";  

                var top=topScroll+parseInt(topDiv);  

                timer=setInterval(function(){  

                    //$(".test").css("top", top+"px");  

                     $("#splitsuspend_div").stop(true).animate({"top":top},50);  

                },50)  

              })  

        })  

        function getScroll(){  

             var bodyTop = 0;    

             if (typeof window.pageYOffset != 'undefined') {    

                 bodyTop = window.pageYOffset;    

             } else if (typeof document.compatMode != 'undefined' && document.compatMode != 'BackCompat') {    

                 bodyTop = document.documentElement.scrollTop;    

             }    

             else if (typeof document.body != 'undefined') {    

                 bodyTop = document.body.scrollTop;    

             }    

             return bodyTop  

        } 

좋은 웹페이지 즐겨찾기