CSSStyleDeclaration setProperty () 메서드
예시
새 CSS 속성을 설정합니다.
var declaration = document.styleSheets[0].cssRules[0].style;
var setprop = declaration.setProperty("background-color",
"yellow");
정의 및 사용
setProperty() 메서드는 CSS 선언 블록에서 새 속성을 설정하거나 기존 CSS 속성을 수정합니다.
브라우저 지원
Method | |||||
---|---|---|---|---|---|
setProperty() | Yes | 9.0 | Yes | Yes | Yes |
통사론
object.setProperty(propertyname, value, priority)
매개변수 값
Parameter | Description |
---|---|
propertyname | Required. A String representing the name of the property to set |
value | Optional. A String representing the new value |
priority | Optianal. A String representing if the property's priority should be set to
important or not. Legal values: "important" undefined "" |
기술적 세부 사항
DOM 버전: | CSS 객체 모델 |
---|---|
반환 값: | 찾으시는 주소가 없습니다 |
더 많은 예
예시
"중요" 우선 순위로 새 CSS 속성을 설정합니다.
var declaration = document.styleSheets[0].cssRules[0].style;
var setprop = declaration.setProperty("background-color",
"yellow", "important");
예시
기존 CSS 속성 수정:
var declaration = document.styleSheets[0].cssRules[0].style;
var setprop = declaration.setProperty("color",
"blue");
❮ CSSStyleDeclaration 객체