StylePropertyMapReadOnly: phương thức getAll()

Khả dụng hạn chế

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

Phương thức getAll() của giao diện StylePropertyMapReadOnly trả về một mảng các đối tượng CSSStyleValue chứa các giá trị của thuộc tính được cung cấp.

Cú pháp

js
getAll(property)

Tham số

property

Tên của thuộc tính cần lấy tất cả các giá trị.

Giá trị trả về

Một mảng các đối tượng CSSStyleValue.

Ví dụ

Ví dụ sau sử dụng getAll() với thuộc tính background-image. Một Array được trả về chứa một phần tử cho mỗi hình nền được khai báo.

js
// get a button element
const buttonEl = document.querySelector("button");

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

// use getAll() with the background image property
const allBkImages = allComputedStyles.getAll("background-image");
console.log(allBkImages); // logs an array with each background image as an item

Thông số kỹ thuật

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

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