I am trying to do some calculation with the height of an element and i need to factor in the padding of an element.
var element_top = $(".box").position().top;
var element_height = $(".box").height();
var element_padding = $(".box").css("padding");
the first two give me numbers i can user for addition and subtraction but the the padding gives me 8px…any ideas…I am trying to use the padding to subract from the height to get the actual height from the box element
You could just use
outerHeight()and skip the need for performing the calculations yourself:For individual values (padding, margin, etc.) the
parseIntapproach is what I often use, as has been suggested already.