Document: styleSheetSets property

Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.

Non-standard: This feature is not standardized. We do not recommend using non-standard features in production, as they have limited browser support, and may change or be removed. However, they can be a suitable alternative in specific cases where no standard option exists.

Thuộc tính chỉ đọc styleSheetSets trả về một danh sách trực tiếp của tất cả các bộ bảng kiểu hiện có sẵn.

Giá trị

Một danh sách các bộ bảng kiểu có sẵn.

Ví dụ

Cho một phần tử <ul> (danh sách) có ID là "sheetList", bạn có thể điền nó với tên của tất cả các bộ bảng kiểu có sẵn bằng mã như sau:

js
const list = document.getElementById("sheetList");
const sheets = document.styleSheetSets;

list.textContent = "";

for (const sheet of sheets) {
  const item = document.createElement("li");
  item.textContent = sheet;
  list.appendChild(item);
}

Ghi chú

Danh sách các bộ bảng kiểu có sẵn được xây dựng bằng cách liệt kê tất cả các bảng kiểu có sẵn cho tài liệu, theo thứ tự chúng được liệt kê trong thuộc tính Document.styleSheets, thêm title của mỗi bảng kiểu có tiêu đề vào danh sách. Các bản sao bị loại bỏ khỏi danh sách (sử dụng phép so sánh phân biệt hoa thường).

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

Xem thêm