Metoda jQuery outerHeight()

❮ Metody jQuery HTML/CSS

Przykład

Zwróć zewnętrzną wysokość elementu <div>:

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

Definicja i użycie

Metoda outerHeight() zwraca zewnętrzną wysokość PIERWSZEGO dopasowanego elementu.

Jak pokazano na poniższym obrazku, ta metoda obejmuje dopełnienie i obramowanie.

Porada: Aby uwzględnić margines, użyj externalHeight(true).

jQuery Wymiary


Powiązane metody:

  • width() - Ustawia lub zwraca szerokość elementu
  • height() - Ustawia lub zwraca wysokość elementu
  • innerWidth() — Zwraca szerokość elementu (wraz z dopełnieniem)
  • innerHeight() — Zwraca wysokość elementu (w tym dopełnienie)
  • outerWidth() — Zwraca szerokość elementu (w tym dopełnienie i obramowanie).

Składnia

$(selector).outerHeight(includeMargin)

Parameter Description
includeMargin Optional. A Boolean value specifying whether or not to include the margin
  • false - Default. Does not include the margin
  • true - Includes the margin

Spróbuj sam - przykłady


Określ, czy uwzględnić margines.


Jak używać width(), height(), innerHeight(), innerWidth(), outerWidth() i outerHeight().


❮ Metody jQuery HTML/CSS