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://codercto.com/courses/l/35.html

查看所有标签

The Little MLer

The Little MLer

Matthias Felleisen、Daniel P. Friedman、Duane Bibby、Robin Milner / The MIT Press / 1998-2-19 / USD 34.00

The book, written in the style of The Little Schemer, introduces instructors, students, and practicioners to type-directed functional programming. It covers basic types, quickly moves into datatypes, ......一起来看看 《The Little MLer》 这本书的介绍吧!

随机密码生成器
随机密码生成器

多种字符组合密码

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

URL 编码/解码

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

正则表达式在线测试