javascript - jquery scrolling function not working properly -


i'm using code change position when scroll. problem when scrolled top of page css top:'0px' not working. here code.

window.onload = function() {      var stickysidebar = $('.bk-form-wrap').offset().top;     var $div = $('div.bk-form-wrap');     $(window).scroll(function() {          if ($(window).scrolltop() > stickysidebar) {             $div.css({                  position:'fixed',                  height: '70px'             });             $div.animate({                 top: '95px',                 //top:'100%',                // margintop: - $div.height()              });         }         else {           }             if ($(this).scrolltop() == 0) {              //call event here              $div.css({                  position:'relative',              });              $div.animate({                 top:'0px',              });         }     }); }; 

and link page. plese help. thanks.

try this.

var $div = $('div.bk-form-wrap');   $(window).scroll(function() {     var stickysidebar = $('.bk-form-wrap').offset().top;     if ($(window).scrolltop() > stickysidebar) {          $div.css({              position:'fixed',              height: '70px'               },1000);         $div.animate({             top: '95px'             //top:'100%',            // margintop: - $div.height()          });     }      else if ($(window).scrolltop() == 0) {        //call event here          $div.css({              position:'relative'               });            $div.animate({             top: '0px'         },500);     }    }); 

Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -