Home >Web Front-end >JS Tutorial >jQuery Help CSS Size (5) outerHeight, outerWidth_jquery

jQuery Help CSS Size (5) outerHeight, outerWidth_jquery

WBOY
WBOYOriginal
2016-05-16 18:41:471015browse

In order to better control the elements to meet our requirements, we can get the height and width of this part through outerHeight(options) and outerWidth(options).

outerHeight(options)
Get the outer height of the first matching element (default includes padding and border).
This method works for both visible and hidden elements.
Return value: Integer
Parameters:
options(Boolean): (false) When set to true, margins are included in the calculation.
Example:
Get the outer height of the first paragraph.
HTML code:

Hello

2nd Paragraph



jQuery code:
var p = $("p:first") ;
$("p:last").text( "outerHeight:" p.outerHeight() " , outerHeight(true):" p.outerHeight(true) );

Result:

Hello

outerHeight: 35, outerHeight(true):55



outerWidth(options)
Get the outer width of the first matching element (default includes filler and frame).
This method works for both visible and hidden elements.
Return value: Integer
Parameters:
options(Boolean): (false) When set to true, margins are included in the calculation.
Example:
Get the outer width of the first paragraph.
HTML code:

Hello

2nd Paragraph



jQuery code:

var p = $("p: first");
$("p:last").text( "outerWidth:" p.outerWidth() " , outerWidth(true):" p.outerWidth(true) );

result :

Hello

outerWidth: 65 , outerWidth(true):85

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn