CSSPageRule: thuộc tính selectorText

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since February 2023.

Thuộc tính selectorText của giao diện CSSPageRule lấy và thiết lập các bộ chọn liên kết với CSSPageRule.

Giá trị

Một chuỗi.

Ví dụ

Stylesheet bao gồm hai quy tắc @page. Thuộc tính selectorText sẽ trả về văn bản bộ chọn chính xác của :first dưới dạng chuỗi.

css
@page {
  margin: 1cm;
}

@page :first {
  margin: 2cm;
}
js
const myRules = document.styleSheets[0].cssRules; // Two myRules
console.log(myRules[1].selectorText); // ":first"

Thông số kỹ thuật

Thông số kỹ thuật
CSS Object Model (CSSOM)
# dom-csspagerule-selectortext

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