Pete Pete - 1 year ago 103
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

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download