CSSStyleDeclaration item () Method
ตัวอย่าง
ส่งคืนชื่อคุณสมบัติ CSS แรกจากการประกาศสไตล์ขององค์ประกอบ "ex1":
var style = document.getElementById("ex1").style;
var propname = style.item(0);
alert(propname);
ความหมายและการใช้งาน
รายการ () วิธีการส่งกลับชื่อคุณสมบัติ 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 Object Model |
---|---|
คืนมูลค่า: | สตริงแทนชื่อของคุณสมบัติ |
ตัวอย่างเพิ่มเติม
ตัวอย่าง
วนรอบการประกาศสไตล์ขององค์ประกอบทั้งหมด:
for (i = 0; i < elmnt.style.length; i++) {
txt +=
elmnt.style.item(i)
}
❮วัตถุ CSSStyleDeclaration