English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The innerHeight() method gets or sets the internal height of the selected element (including padding, but not including margin and border).
When using the innerHeight() methodGetWhen setting the height, it returnsThe first selected elementheight.
When using the innerHeight() methodSetWhen setting the height, it will setAll selected elementsheight.
As shown in the figure below, the innerHeight() method includes padding, but does not include border and margin:
The height value can also be relative. If a leading+=-If a character sequence is assigned, the target height is calculated by adding or subtracting the given number from the current value (for example innerHeight(" + = 100))。
Get internal height:
$(selector).innerHeight()
Set internal height:
$(selector).innerHeight(value)
Get the internal height of the DIV element:
$("div").click(function(){ $(this).innerHeight(); });Teste e Veja‹/›
Configure the internal height of all paragraphs:
$("button").click(function(){ $("p").innerHeight("100); });Teste e Veja‹/›
Configure a different unit for the internal height of all paragraphs:
$("#btn1").click(function(){ $("p").innerHeight("100); }); $("#btn2").click(function(){ $("p").innerHeight("7em); }); $("#btn3").click(function(){ $("p").innerHeight("100vh); });Teste e Veja‹/›
Exibir a diferença entre width(), height(), innerHeight(), innerWidth(), outerWidth() e outerHeight():
$("button").click(function(){ $("div").width(); $("div").innerWidth(); $("div").outerWidth(); $("div").height(); $("div").innerHeight(); $("div").outerHeight(); });Teste e Veja‹/›
Parâmetro | Descrição |
---|---|
value | Número inteiro representando pixels, ou número inteiro com unidade opcional opcional (como string) |