i have function stick nav sidebar top after scrolling.but when screen minimizes logo on top shortens , position of nav changes.so wrote 'if' function inside first 1 solve problem.now position correct nav side bar fixing on top while scrolling.can please me....the function below....
$(function() { var stickyheadertop = $('#myscrollspy').offset().top; var yy = document.getelementbyid("cor").clientheight; $(window).scroll(function() { if ($(window).scrolltop() > stickyheadertop) { $('#myscrollspy').css({ position: 'fixed', top: '8px', left: '0px' }); $('#my').css({ position: 'absolute', right: '0px' }); } else { setinterval(function() { if (yy < '490') { var yu = '500' - yy; $('#myscrollspy').css({ position: 'absolute', top: '' 700 '-yy', left: '0px' }); $('#my').css({ position: 'absolute', right: '0px' }); } }, 30); } }); });
you have syntax issues, have mentioned them in comments below.
if (yy < 490) { //syntax issue here var yu = 500 - yy; //syntax issue here $('#myscrollspy').css({ position: 'absolute', top: (700 - yy)+'px', //syntax issue here left: '0px' }); $('#my').css({ position: 'absolute', right: '0px' }); } document.getelementbyid("cor").clientheight return int(number).
check element.clientheight
note: property round value integer. if need fractional value, use
element.getboundingclientrect().
Comments
Post a Comment