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

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 StylePropertyMapReadOnly.keys() trả về một iterator mảng mới chứa các khóa của mỗi phần tử trong StylePropertyMapReadOnly.

Cú pháp

js
keys()

Tham số

Không có.

Giá trị trả về

Một Array mới.

Ví dụ

Trong ví dụ này, sử dụng phương thức keys() để truy cập các thuộc tính trong Element.computedStyleMap().

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

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

// keys returns an iterable list of properties
const props = allComputedStyles.keys();
console.log(props.next().value); // returns align-content

Thông số kỹ thuật

Tính năng này dường như chưa được định nghĩa trong bất kỳ thông số kỹ thuật nào.

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