jQuery externalHeight用于隐藏元素 [英] jQuery outerHeight for hidden element

查看:97
本文介绍了jQuery externalHeight用于隐藏元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在获取列表项的外部高度时遇到问题-与以下帖子类似: jQuery:获取jQuery中隐藏元​​素的高度

I am having a problem with getting the outer height of a list item - similar to the below post: jQuery: Get height of hidden element in jQuery

这是我的代码:

function tabload() {
    $('.tab li:first-child').addClass('selected');

    $(".tab ul").css({ 'position': 'absolute', 'visibility': 'hidden', 'display': 'block'});

    var h = $(".tab ul").outerHeight(true);

    $(".tab ul").css("height", h);

    $(".tab ul").css({'position': 'relative', 'visibility': 'visible', 'display': 'none' });
};

我做错什么了吗?

推荐答案

由于在stackoverflow上还有其他一些类似的问题,因此我之前已经在博客中介绍了此问题.看一下博客文章

I have blogged about this issue before since there are a few other similar questions here on stackoverflow. Take a look at the code in this blog post

我最初只是为width方法开发的,但是根据注释,代码已发展为包括内部/外部尺寸.

I initially developed it just for the width method, but based on comments the code has evolved to include inner/outer dimensions.

这篇关于jQuery externalHeight用于隐藏元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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