jQuery的外部高度为零? [英] jQuery outer height is zero?

查看:93
本文介绍了jQuery的外部高度为零?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么我的搜索表格的高度为0?高度至少为20px.

Why is the height of my search form 0? It's at least 20px high.

jQuery(function($) { // Document ready
    var s_height = $("#search_form").outerHeight(); // Height of searchform
    alert(s_height) // 0

推荐答案

使用jQuery,您只能获取可见的元素的高度.因此,请确保它在您的JS运行时可见,或者使用

With jQuery you can only get the height of an element if it is visible. So make sure that it is visible at the time that your JS runs, or use one of the several workarounds if you need it to be hidden at the time.

正如您在评论中提到的那样,div被隐藏然后逐渐消失.

As you mentioned in your comments, the div was hidden and then fading in.

这篇关于jQuery的外部高度为零?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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