jQuery

[HTML_CSS] JQ - outerHeight() 메서드 - 요소 높이 반환 (height + padding + border + margin △)

목차
  1. outerHeight() 예제 - height + padding + border
  2. outerHeight() 정의
  3. outerHeight() 구문
  4. outerHeight() 예제 - height + padding + border + margin
  5. outerHeight() 예제 - 관련 메서드

 

outerHeight() 예제 - height + padding + border

 

<style>

div {height:100px;width:200px;padding:10px;margin:3px;border:1px solid blue;background-color:yellow;}

</style>


<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

<script>

$(document).ready(function(){

  $("button").click(function(){

        alert("div 요소의 outerHeight: " + $("div").outerHeight());

  });

});

</script>


<div style="">홈짱닷컴 Homzzang.com</div>

<br>

<button>클릭</button>

 

결과보기

※ 결과값: 122 = 100 + 10 x 2 + 1 x 2

 

outerHeight() 정의

 

첫 번째 일치 요소의 outerHeight 높이 반환.

 


 

1. 매개변수 값에 따라 outerHeight 달라짐.

  • false (기본값) 경우: outerHeight = Height + Padding + Border
  • true 경우: outerHeight = Height + Padding+ Border + Margin

 

2. 관련 메서드

width() - 선택요소의 너비 반환/설정.

innerWidth() - (width + padding) 반환.

outerWidth() - (width + padding + border) 반환.

outerWidth(true) - (width + padding + border + margin) 반환.

 

height() - 선택요소의 높이 반환/설정.

innerHeight() - (height + padding) 반환.

outerHeight() - (height + padding + border) 반환.

outerHeight(true) - (height + padding + border + margin) 반환.

 

3. 예제 더 보기

https://api.jquery.com/outerheight/

 

 

outerHeight() 구문

 

$(selector).outerHeight(includeMargin)

 


[매개변수]

 

includeMargin

선택. margin 포함 여부.

  • false 경우 : margin 포함 X (기본값)
  • true 경우 : margin 포함 O

 

 

outerHeight() 예제 - height + padding + border + margin

 

<style>

div {height:100px;width:200px;padding:10px;margin:3px;border:1px solid blue;background-color:yellow;}

</style>


<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

<script>

$(document).ready(function(){

  $("button").click(function(){

        alert("div 요소의 outerHeight: " + $("div").outerHeight(true));

  });

});

</script>


<div style="">홈짱닷컴 Homzzang.com</div>

<br>

<button>클릭</button>

 

결과보기

※ 결과값: 128 = 100 + 10 x 2 + 1 x 2 + 3 x 2

 

outerHeight() 예제 - 관련 메서드

 

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

<script>

$(document).ready(function(){

  $("button").click(function(){

    var txt = "";

    txt += "width: " + $("#hz").width() + "</br>";

    txt += "innerWidth: " + $("#hz").innerWidth() + "</br>";

    txt += "outerWidth: " + $("#hz").outerWidth() + "</br>";

    txt += "outerWidth (margin 포함O): " + $("#hz").outerWidth(true) + "</br>" + "</br>";

  

    txt += "height: " + $("#hz").height() + "</br>";   

    txt += "innerHeight: " + $("#hz").innerHeight() + "</br>";

    txt += "outerHeight: " + $("#hz").outerHeight() + "</br>";

    txt += "outerHeight(margin 포함): " + $("#hz").outerHeight(true) + "</br>";

    $("#hz").html(txt);

  });

});

</script>


<style>

#hz {

    height:300px;

    width:300px;

    padding:10px;

    margin:4px;

    border:2px solid blue;

    background-color:lightblue;

}

</style>


<div id="hz"></div>

<button>클릭</button>

 

결과보기 



분류 제목
Event JQ - off() 메서드 ★ - on() 메서드로 부착된 이벤트핸들러 제거 (= off메서드 = 오프메서드…
Event JQ - one() 메서드 - 요소마다 오직 한번만 이벤트 실행. (= one메서드 = 원메서드) ※ 현재값…
Event JQ - $.proxy() 메서드 - 기존 함수를 가져와 특정 구문을 가진 새 함수로 반환. (= proxy…
Event JQ - ready() 메서드 - DOM이 완전 로드 시 실행할 함수 지정. (= ready메서드 = 레디 …
Event JQ - resize() 메서드 - 창크기변경이벤트 (= 윈도우창 리사이즈이벤트 = resize메서드 = 리…
Event JQ - scroll() 메서드 ★★★ - 스크롤 이벤트를 부착/촉발 (jquery, scroll, even…
Event JQ - select() 메서드 - 입력창의 문자열 드래그 선택. (= select이벤트 = 실렉트/셀렉트 …
Event JQ - submit() 메서드 ★ - 폼 입력값 전송 이벤트 촉발/실행함수 지정. (= submit메서드 …
Event JQ - toggle() 메서드 - JQ 1.9 폐기완료. / 여러 클릭 이벤트간 상호전환. (= togg…
Event JQ - trigger() 메서드 ★ - 지정 이벤트 수동 촉발과 이벤트 기본동작 수행. (= trigger…
Event JQ - triggerHandler() 메서드 - 지정 이벤트 수동 촉발만 함. (= 트리거핸들러 메서드)
Event JQ - unbind() 메서드 - JQ 3.0 폐기예고, off() 메서드로 대체. 추가된 이벤트핸들러 제…
Event JQ - undelegate() 메서드 - JQ 3.0 폐기예고. off() 메서드로 대체. / 이벤트핸들러…
Event JQ - unload() 메서드 - JQ 3.0 폐기완료. / 페이지 떠날 때 실행. (= 언로드 메서드)
Effect JQ - clearQueue() 메서드 - 선택요소에서 실행 대기 함수 모두 제거/삭제. (= clearQu…
10/20
목록
 홈  PC버전 로그인 일본어
그누앞단언어 1
그누뒷단언어
그외코딩언어
그누보드
제작의뢰
Q&A
커뮤니티 1
웹유틸
회원센터
홈짱닷컴 PC버전 로그인