Get the position of div on page scroll in jquery -


i'm stuck @ point fix position of menu div in center of page or sometime on top depends on content. wanna fix position of div when scroll page display in top of page(even in center or top or bottom).please let me know how can position of div , apply css position fixed when reach on top of page using jquery. example http://new.livestream.com/live-video-tools

i made try : see jsfiddle

thing change css attribute of containers need fixed once scroll reach :

$(document).ready(function(){     var imenutop = $('.menu').offset().top;     $(window).scroll(function(){         var iwintop = $(this).scrolltop();         if(iwintop >= imenutop)             $('.menu').css({                 position:'fixed',                 top:0});         else             $('.menu').css('position','static');              }); }); 

working firefox, not sur others...

edit : it's draft, might have adapt e.g. if there scroll when loading, can occur using browser button.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -