I have some attributes that I am trying to change with the .css in jquery but for some reason the code does not work. Is there something wrong with the parenthesis?
the original value is set as so padding: 40px 0 0;
here is the jquery that changes the above value:
var header = $('#main'), padding = '40px'; $(window).scroll(function() { if ($(this).scrollTop() <= padding / 2) { header.css({ 'padding-top': -($(this).scrollTop() - padding) + "px", 'padding-bottom': -($(this).scrollTop() - padding) + "px" });
padding; they're invalid lengths and will be discarded by the browser.$(this).scrollTop() <= padding / 2is always false:'40px' / 2isNaN, and any compaison involvingNaNis false.