StylePropertyMapReadOnly: thuộc tính size

Khả dụng hạn chế

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Thuộc tính chỉ đọc size của giao diện StylePropertyMapReadOnly trả về một số nguyên dương chứa kích thước của đối tượng StylePropertyMapReadOnly.

Giá trị

Một số nguyên dương.

Ví dụ

Ví dụ này sử dụng thuộc tính size để trả về tổng số mục trong computedStyleMap của phần tử button.

js
// grab our element
const buttonEl = document.querySelector("button");

// we can retrieve all computed styles with `computedStyleMap`
const allComputedStyles = buttonEl.computedStyleMap();

// use size to get the total styles within the map
const amountStyles = allComputedStyles.size;
console.log(amountStyles); // logs 338

Thông số kỹ thuật

Thông số kỹ thuật
CSS Typed OM Level 1
# dom-stylepropertymapreadonly-size

Tương thích trình duyệt