jQuery API 返回首页目录 | jQuery API 中英文对照版
height(val)

height(val)

为每个匹配的元素设置CSS高度(width)属性的值。如果没有明确指定单位(如:em或%),使用px。

返回值:jQuery

参数:

  • val (String|Number): 要设置的高度值
 

示例:

$("p").height(20);

HTML 代码:

<p>This is just a test.</p>

结果:

<p style="height:20px;">This is just a test.</p>

示例:

$("p").height("20em");

HTML 代码:

<p>This is just a test.</p>

结果:

<p style="height:20em;">This is just a test.</p>

 

height( val )

Set the CSS height of every matched element. If no explicit unit was specified (like 'em' or '%') then "px" is added to the width.

Return value: jQuery
Parameters:

  • val (String|Number): Set the CSS property to the specified value.
 

Example:

 $("p").height(20);  

Before:

 <p>This is just a test.</p>  
Result:
 <p style="height:20px;">This is just a test.</p>

Example:

 $("p").height("20em");  

Before:

 <p>This is just a test.</p>  
Result:
 <p style="height:20em;">This is just a test.</p>  
相关链接
asp之家 | jQuery官方网站 | jQuery中文网 | 电子书作者网站 | 电子书作者blog