这是
实验性技术
检查
浏览器兼容性表格
要小心谨慎在生产中使用这之前。
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. |
工作草案 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
element
|
Chrome No | Edge No |
Firefox
75
Disabled
|
IE No | Opera No | Safari No | WebView Android No | Chrome Android No |
Firefox Android
67
Disabled
|
Opera Android No | Safari iOS No | Samsung Internet Android No |
完整支持
不支持
实验。期望将来行为有所改变。
用户必须明确启用此特征。
使用非标名称。
CSSPseudoElement
element
type