当元素被隐藏时,jQuery.outerHeight不工作? [英] jQuery.outerHeight doesn't work when element is hidden?

查看:160
本文介绍了当元素被隐藏时,jQuery.outerHeight不工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找出一个元素的外部高度(包括填充),它似乎不工作。

I'm trying to find out the outer height of a element (including padding) and it doesn't seem to work.

我总是得到0。因为元素是隐藏的?

I always get 0. Is it because the element is hidden?

元素包含在一个具有auto高度的绝对定位的元素内,但我不认为这应该是一个问题,因为元素是相对的...

The element is contained inside a absolute-positioned element with "auto" height, but I don't think that should be a issue, because the element is relative...

推荐答案

隐藏元素有外部高度,

<div id="aaa" style="visibility:hidden">aaa</div>
<div id="bbb" style="visibility:hidden"></div>

alert($("#aaa").outerHeight());// returns 20

alert($("#bbb").outerHeight()); //returns 0

请添加您的html代码以获得更完整的答案

please add your html code for a more complete answer

这篇关于当元素被隐藏时,jQuery.outerHeight不工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆