Ghooti Farangi
Ghooti Farangi

Reputation: 20156

How can I get/set the height of an hidden element by jquery?

How can I get/set the height of an hidden element by jquery?

<div id="test" style="display:none">...</div>

$("#test").height() return 0

$("#test").height(30) return exception.

Upvotes: 2

Views: 134

Answers (2)

uadnal
uadnal

Reputation: 11425

$("#test").ccs("height", "30px");

or

$("#test").height("30px");

It is returning 0 because it is hidden.

Upvotes: 2

Nicola Peluchetti
Nicola Peluchetti

Reputation: 76870

Yo should do (with quotes):

  $("#test").height('30') 

$("#test").height() returns 0 if you don't define a default width in an external css and if the element is hidden.

Upvotes: 0

Related Questions