• 회원가입
  • 로그인
  • 구글아이디로 로그인

[DOM_Event] JS - defaultPrevented 속성 - 이벤트에 preventDefault() 메서드가 호출되었는지 여부 체크 (= defaultPrevented속성 = 디폴트프리벤티드속성)

목차

  1. defaultPrevented 예제 - preventDefault() 메서드 호출 여부 체크
  2. defaultPrevented 정의
  3. defaultPrevented 구문

 

defaultPrevented 예제 - preventDefault() 메서드 호출 여부 체크

 

<a id="hz" href="https://homzzang.com/">홈짱닷컴 바로가기</a>


<script>

document.getElementById("hz").addEventListener("click", function(event){

  event.preventDefault()

  alert("preventDefault() 메서드 호출 여부: " + event.defaultPrevented);

});

</script>

 

결과보기

 

defaultPrevented 정의

 

해당 이벤트에 대해 preventDefault() 메서드가 호출되었는지 여부 체크.

 


 

1.

IE9 이상 주요 최신 브라우저 모두 지원

 

2. MDN defaultPrevented 예제 보기

https://developer.mozilla.org/en-US/docs/Web/API/Event/defaultPrevented

 

 

defaultPrevented 구문

 

event.defaultPrevented

 


[반환값]

 

  • preventDefault() 메서드 호출 O 경우, true 반환.
  • preventDefault() 메서드 호출 X 경우, false 반환.

 



분류 제목
DOM_Style JS - fontSize 속성 - 글자크기 (= 폰트크기 = fontSize속성 = 폰트사이즈 속성)
DOM_Style JS - fontStyle 속성 - 글자모양 (= font-style속성 = 글씨체모양 = 글씨모양 = 글자…
DOM_Style JS - fontVariant 속성 - (소문자/보통) 크기의 대문자로 설정/반환.
DOM_Style JS - fontWeight 속성 - 글자굵기 (= font-weight속성 = 폰트굵기 = 글씨체굵기 =글…
DOM_Style JS - fontSizeAdjust -
DOM_Style JS - fontStretch -
DOM_Style JS - hangingPunctuation -
DOM_Style JS - height 속성 - 요소 높이 설정/반환 (= height속성 = 하이트속성) ※ 요소 세로길이 …
DOM_Style JS - hyphens -
DOM_Style JS - icon -
DOM_Style JS - imageOrientation -
DOM_Style JS - isolation -
DOM_Style JS - justifyContent 속성 - flex 항목 세로 정렬 설정/반환 (= justifyConte…
DOM_Style JS - left 속성 - 왼쪽기준 (= left속성 = 좌측기준 = 레프트속성, 상속 X)
DOM_Style JS - letterSpacing 속성 ★ - 글자 간격 반환/설정 ( 텍스트사이띄우기 = 문자 간격 = 글…
DOM_Style JS - lineHeight 속성 ★ - 텍스트라인높이 (= line-height속성 = 텍스트줄높이 = 글…
DOM_Style JS - listStyle -
DOM_Style JS - listStyleImage -
DOM_Style JS - listStylePosition -
DOM_Style JS - listStyleType 속성 - 리스트 마커 모양 (= listStyleType속성 / 리스트스타…
47/67
목록
찾아주셔서 감사합니다. Since 2012