javascript - Jquery move element on scroll? -



javascript - Jquery move element on scroll? -

example: have menu horisontally (on header), if scroll page downwards (about >100px top) menu (horisontal) move left side of browser (vertical) , fixed there...

any help?

try this:

here working jsfiddle , source.

$(window).scroll(function() { var headerh = $('.header').outerheight(true); //this calculate header's total height, borders, margins, paddings var scrolltopval = $(this).scrolltop(); if ( scrolltopval > headerh ) { $('#subnav').css({'position':'fixed','top' :'0px'}); } else { $('#subnav').css({'position':'static','top':'0px'}); } var scrollleftval = $(this).scrollleft(); if ( scrollleftval > 1 ) { alert('i scrolled left'); } });

javascript jquery

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -