开发者

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

开发者 https://www.devze.com 2023-03-19 22:49 出处:网络
How can I get/set the height of an hidden element by jquery? <div id=\"test\" styl开发者_运维技巧e=\"display:none\">...</div>

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

<div id="test" styl开发者_运维技巧e="display:none">...</div>

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

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


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

or

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

It is returning 0 because it is hidden.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消