CSSStyleDeclaration 항목 () 메서드
예시
"ex1" 요소의 스타일 선언에서 첫 번째 CSS 속성 이름을 반환합니다.
var style = document.getElementById("ex1").style;
var propname = style.item(0);
alert(propname);
정의 및 사용
item() 메서드는 CSS 선언 블록에서 인덱스별로 CSS 속성 이름을 반환합니다.
인덱스는 0에서 시작합니다.
브라우저 지원
Method | |||||
---|---|---|---|---|---|
item() | Yes | 9.0 | Yes | Yes | Yes |
통사론
style.item(index)
매개변수 값
Parameter | Description |
---|---|
index | Required. A number representing the index of the CSS property |
기술적 세부 사항
DOM 버전: | CSS 객체 모델 |
---|---|
반환 값: | 속성의 이름을 나타내는 문자열 |
더 많은 예
예시
모든 요소의 스타일 선언을 반복합니다.
for (i = 0; i < elmnt.style.length; i++) {
txt +=
elmnt.style.item(i)
}
❮ CSSStyleDeclaration 객체