views:

123

answers:

2

I want to carry out two different functions based on the height of a div. How would I write out a conditional that checks the style before deciding?

+3  A: 

You have:

var e = $("someSelectorThatGetsTheElement");
if (e.height() < 50) {
    // do something;
} else {
    // do something else;
}

EDIT: I made a small mistake, e.height is actually a function, so need to add the "()".

Prody
A: 

You can use the height() method. The css(name) method can be used to return any style property.

kgiannakakis