这是 实验性技术
检查 浏览器兼容性表格 要小心谨慎在生产中使用这之前。

element 只读特性在 CSSPseudoElement interface returns a reference to the originating element of the pseudo-element, in other words its parent element.

句法

var originatingElement = cssPseudoElement.element;
					

元素 representing the pseudo-element's originating element.

范例

The example below demonstrates the relationship between CSSPseudoElement.element and Element.pseudo() :

const myElement = document.querySelector('q');
const cssPseudoElement = myElement.pseudo('::after');
const originatingElement = cssPseudoElement.element;
console.log(myElement === originatingElement);                  // Outputs true
console.log(myElement.parentElement === originatingElement);    // Outputs false
console.log(myElement.lastElementChild === cssPseudoElement);   // Outputs false
console.log(myElement.lastChild === cssPseudoElement);          // Outputs false
console.log(myElement.nextElementSibling === cssPseudoElement); // Outputs false
console.log(myElement.nextSibling === cssPseudoElement);        // Outputs false
					

规范

规范 状态 注释
CSS Pseudo-Elements Level 4
The definition of 'element' in that specification.
工作草案 初始定义。

浏览器兼容性

The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
element Chrome No Edge No Firefox 75 Disabled
75 Disabled
Disabled From version 75: this feature is behind the dom.css_pseudo_element.enabled preference. To change preferences in Firefox, visit about:config.
不支持 67 — 75 Disabled
Disabled From version 67 until version 75 (exclusive): this feature is behind the dom.animations-api.getAnimations.enabled preference. To change preferences in Firefox, visit about:config.
不支持 63 — 67 Alternate Name Disabled
Alternate Name Uses the non-standard name: parentElement
Disabled From version 63 until version 67 (exclusive): this feature is behind the dom.animations-api.getAnimations.enabled preference. To change preferences in Firefox, visit about:config.
不支持 47 — 63 Alternate Name Disabled
Alternate Name Uses the non-standard name: parentElement
Disabled From version 47 until version 63 (exclusive): this feature is behind the dom.animations-api.core.enabled preference. To change preferences in Firefox, visit about:config.
IE No Opera No Safari No WebView Android No Chrome Android No Firefox Android 67 Disabled
67 Disabled
Disabled From version 67: this feature is behind the dom.animations-api.getAnimations.enabled preference. To change preferences in Firefox, visit about:config.
不支持 63 — 67 Alternate Name Disabled
Alternate Name Uses the non-standard name: parentElement
Disabled From version 63 until version 67 (exclusive): this feature is behind the dom.animations-api.getAnimations.enabled preference. To change preferences in Firefox, visit about:config.
不支持 47 — 63 Alternate Name Disabled
Alternate Name Uses the non-standard name: parentElement
Disabled From version 47 until version 63 (exclusive): this feature is behind the dom.animations-api.core.enabled preference. To change preferences in Firefox, visit about:config.
Opera Android No Safari iOS No Samsung Internet Android No

图例

完整支持

完整支持

不支持

不支持

实验。期望将来行为有所改变。

实验。期望将来行为有所改变。

用户必须明确启用此特征。

用户必须明确启用此特征。

使用非标名称。

另请参阅

元数据

  • 最后修改:
  1. CSSPseudoElement
  2. 特性
    1. element
    2. type
  3. 继承:
    1. EventTarget