jQuery 높이() 메서드

❮ jQuery HTML/CSS 메소드

예시

<div> 요소의 높이를 반환합니다.

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

정의 및 사용

height() 메서드는 선택한 요소의 높이를 설정하거나 반환합니다.

이 메서드를 사용하여 높이를 반환하면 첫 번째로 일치하는 요소의 높이를 반환합니다 .

이 방법을 사용하여 높이를 설정 하면 일치하는 모든 요소의 높이를 설정합니다.

아래 이미지에서 알 수 있듯이 이 메서드에는 패딩, 테두리 또는 여백이 포함되지 않습니다.

jQuery 차원


관련 방법:

  • width() - 요소의 너비를 설정하거나 반환합니다.
  • innerWidth() - 요소의 너비를 반환합니다(패딩 포함).
  • innerHeight() - 요소의 높이를 반환합니다(패딩 포함).
  • outerWidth() - 요소의 너비를 반환합니다(패딩 및 테두리 포함).
  • outerHeight() - 요소의 높이를 반환합니다(패딩 및 테두리 포함).


통사론

높이 반환:

$(selector).height()

높이 설정:

$(selector).height(value)

함수를 사용하여 높이 설정:

$(selector).height(function(index,currentheight))

Parameter Description
value Required for setting height. Specifies the height in px, em, pt, etc.
Default unit is px
function(index,currentheight) Optional. Specifies a function that returns the new height of selected elements
  • index - Returns the index position of the element in the set
  • currentheight - Returns the current height of the selected element

직접 해보십시오 - 예


높이 설정 다른 단위를 사용하여 요소 높이를 설정하는 방법입니다.


를 사용하여 높이 증가 요소의 높이를 높이는 함수를 사용하는 방법.


의 현재 높이를 반환하는 방법입니다.


width(), height(), innerHeight(), innerWidth(), outerWidth() 및 outerHeight() 사용 방법.


❮ jQuery HTML/CSS 메소드