Return the number of styles set on the H1 element:
var elmnt = document.getElementsByTagName("h1")[0];
var x = style.length;
Try it Yourself »
The length property returns the number of style declarations set for the specified element.
Property | |||||
---|---|---|---|---|---|
length | Yes | Yes | Yes | Yes | Yes |
Return the length property:
element.style.length
DOM Version: | CSS Object Model |
---|---|
Return Value: | A Integer, representing the number of style declaration set for the element |
Loop through all the element's style declarations:
for (i = 0; i < elmnt.style.length; i++) {
txt += elmnt.style.item(i)
}
Try it Yourself »
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!