StyleSheet:parentStyleSheet 属性

Baseline Widely available

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

StyleSheet 接口的 parentStyleSheet 属性返回样式表(如果有),其中包含给定的样式表。

一个 StyleSheet 对象。

示例

js
// 查找顶级样式表
const sheet = stylesheet.parentStyleSheet ?? stylesheet;

备注

如果当前样式表是一个顶级的样式表或者如果不支持包含样式表,则这个属性返回 null

Specifications

Specification
CSS Object Model (CSSOM)
# dom-stylesheet-parentstylesheet

Browser compatibility

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
parentStyleSheet

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support