jQuery outerHeight() 方法

jQuery 教程 · 2019-03-27 15:43:21

实例

返回 <div> 元素的外部高度:

$("button").click(function(){ alert($("div").outerHeight()); });

定义和用法

outerHeight() 方法返回第一个匹配元素的外部高度。

如下面的图像所示,该方法包含 padding 和 border。

提示:如需包含 margin,请使用 outerHeight(true)。

jQuery Dimensions

相关方法:

  • width() - 设置或返回元素的宽度
  • height() - 设置或返回元素的高度
  • innerWidth() - 返回元素的宽度(包含 padding)
  • innerHeight() - 返回元素的高度(包含 padding)
  • outerWidth() - 返回元素的宽度(包含 padding 和 border)

语法

$(selector).outerHeight(includeMargin)

参数 描述
includeMargin 可选。布尔值,规定是否包含 margin。
  • false - 默认。不包含 margin。
  • true - 包含 margin。

点击查看所有 jQuery 教程 文章: https://www.codercto.com/courses/l/35.html

查看所有标签

The Haskell School of Music

The Haskell School of Music

Paul Hudak、Donya Quick / Cambridge University Press / 2018-10-4 / GBP 42.99

This book teaches functional programming through creative applications in music and sound synthesis. Readers will learn the Haskell programming language and explore numerous ways to create music and d......一起来看看 《The Haskell School of Music》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

URL 编码/解码
URL 编码/解码

URL 编码/解码