Pete Pete - 3 months ago 16
jQuery Question

get height from style attribute

Is there a way to get the height from a style attribute on a div?

<div style="height:100px;"></div>

I can't use
as this will just return me the current height of the element - I need to check if the style has been set and then get that height if it has


The easiest way is to go straight to the style property:

var heightStyleValue = $("selector for your element")[0].style.height;

You don't want to use jQuery's css function because that will give you the calculated height, not the value from the style object.