jQuery与offsetHeight等效是什么? [英] What is the jQuery equivalent to offsetHeight?

查看:308
本文介绍了jQuery与offsetHeight等效是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

与JavaScript中的offsetHeight等效的jQuery是什么?

What is the jQuery equivalent of offsetHeight in JavaScript?

我想翻译以下代码以使用JQuery

I want to translate the following code to use JQuery

document.querySelector('.site-header').offsetHeight;

推荐答案

方法将与jQuery等效.

The offsetHeight property includes the vertical padding and borders in the height calculation, therefore the .outerHeight() method would be the jQuery equivalent.

此处的示例

$('.site-header').outerHeight();

请注意, .outerHeight()方法采用可选参数来包含垂直边距(s)在高度计算中:

As a side note, the .outerHeight() method takes an optional parameter to include the vertical margin(s) in the height calculation:

$('.site-header').outerHeight(true); // With vertical margins included.

这篇关于jQuery与offsetHeight等效是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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