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

[CSS_Objects] JS - getPropertyPriority() 메서드 - CSS우선순위표시 (= !important) 유무 반환. (= getPropertyPriority메서드 = 겟프라퍼티프라이오러티메서드) (IE9+) ※ !임포턴트 유무 체크

목차

  1. getPropertyPriority() 예제 - !important 유무 반환
  2. getPropertyPriority() 정의
  3. getPropertyPriority() 구문

 

getPropertyPriority() 예제 - !important 유무 반환

 

<style>

#hz {color: red !important;}

</style>


<button onclick="homzzang()">클릭</button>


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

<p id="demo"></p>

 

<script>

function homzzang() {

  var declaration = document.styleSheets[0].cssRules[0].style; // [object CSSStyleDeclaration]

  var priority = declaration.getPropertyPriority("color"); // important

  document.getElementById('demo').innerHTML = priority;

}

</script> 

 

결과보기

 

getPropertyPriority() 정의

 

지정 CSS 속성에 우선 적용 표시인 "!important" 문자열 있는지 여부 반환

 


 

1.

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

 

2.

DOM 버전: CSS Object Model

 

 

getPropertyPriority() 구문

 

object.getPropertyPriority(propertyname)

 


[매개변수]

 

propertyname

필수. 체크할 속성명

 


[반환값]

 

  • 지정 속성에 !important 문자열 존재 시, important 반환.
  • 만약, 없으면, 빈 문자열 반환.

 



분류 제목
CSS_Objects JS - setProperty() 메서드 - 새 CSS속성설정 / 기존CSS속성수정 (= setPropert…
DOM JS - NodeList 속성 - 노드리스트 (= 노드목록)
Basic JS - this 키워드 ★★★★★ - 호출 방식에 따라 지시 대상 다름. (= 디스 키워드)
Functions JS - apply() 메서드 - 함수호출방법3 (= 어플라이메서드)
Functions JS - Closure - 클로저 (전역변수/지역변수/카운터)
Math JS - Math.atanh() 메서드 - 쌍곡선 아크탄젠트 (IE12 이상)
Math JS - Math.acosh() 메서드 - 쌍곡선 아크코사인 (IE12 이상)
Math JS - Math.asinh() 메서드 - 쌍곡선 아크사인 반환 (= asinh 메서드)
Math JS - Math.cbrt() 메서드 - 세제곱근
Math JS - Math.tanh() 메서드 - 쌍곡선 탄젠트 (IE12 이상)
Math JS - Math.trunc() 메서드 - 숫자의 정수부분 추출 (= trunc메서드 = 트런크메서드) (I…
Math JS - Math.cosh() 메서드 - 쌍곡선 코사인
Math JS - Math.sinh() 메서드 - 쌍곡선 사인값 (IE12 이상)
DOM_Event JS - initMouseEvent() 메서드 - 폐기예고. 마우스이벤트초기화
js JS - getRangeAt() 메서드
DOM_Document JS - styleSheets 속성 - 스타일시트집합
js JS - rules 속성 - styleSheets 객체의 속성
DOM_Event JS - cancelBubble 속성 - 부모요소로 이벤트 확산 방지 (= 상위요소로 이벤트확산취소 = 캔슬…
DOM_Event JS - composedPath() 메서드 - 이벤트객체흐름파악 (=이벤트실행객체경로파악 = 컴포우즈드패스메…
js JS - 특정요소 함수실행제외 (= 배열문자열포함검사) ★★★★★
61/67
목록
찾아주셔서 감사합니다. Since 2012