i am trying to have the tipical menu following the webpage scroll,
i wanted to change the position relating the marginTop with the page scroll,
$(document).ready(function(){
$(window).scroll(function(){
var v= $(document).scrollTop();
console.log(v);
if(v>50){
$('.menu').css({'marinTop':v+'px'});
console.log(true);
}else{
$('.menu').css('marginTop','50px');
console.log(false);
}
});
});
but it just wont move the bar… :s
Here:
Fixed 2 things:
".px"(css("marginTop")returns"50px", which can not be compared to a number)position: fixed” instead of a javascript-updated “position: absolute“