jQuery innerWidth() 方法

jQuery 教程 · 2019-03-27 14:26:52

实例

返回 <div> 元素的内部宽度:

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

定义和用法

innerWidth() 方法返回第一个匹配元素的内部宽度。

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

jQuery Dimensions

相关方法:

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

语法

$(selector).innerWidth()

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

查看所有标签

The Shallows

The Shallows

Nicholas Carr / W. W. Norton & Company / 2010-6-15 / USD 26.95

"Is Google making us stupid?" When Nicholas Carr posed that question, in a celebrated Atlantic Monthly cover story, he tapped into a well of anxiety about how the Internet is changing us. He also crys......一起来看看 《The Shallows》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

html转js在线工具
html转js在线工具

html转js在线工具

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试