在jquery中,height()方法用于设置或返回被选元素的高度,可返回第一个匹配元素的高度,语法“$(selector).height()”;但可设置所有匹配元素的高度,语法“$(selector).height(value)”。

本教程操作环境:windows7系统、jquery1.10.2版本、Dell G3电脑。
height() 方法设置或返回被选元素的高度。
当该方法用于返回高度时, 则返回第一个匹配元素的高度。语法格式:
$(selector).height()
当该方法用于设置高度时,则设置所有匹配元素的高度。简单语法格式:
$(selector).height(value)
还可通过调用回调函数来设置高度
$(selector).height(function(index,currentheight))
index - 返回集合中元素的 index 位置。
currentheight - 返回被选元素的当前高度。
示例:
1、获取高度

2、设置高度
注意: 对于em, pt, etc要使用""

相关视频教程推荐:jQuery教程(视频)










