CSSPseudoElement: element プロパティ
Experimental: これは実験的な機能です。
本番で使用する前にブラウザー互換性一覧表をチェックしてください。
element
は CSSPseudoElement
インターフェイスの読み取り専用のプロパティで、擬似要素の元要素、言い換えれば親要素への参照を返します。
値
この擬似要素の元要素を表す Element
です。
例
下記の例は、 CSSPseudoElement.element
と Element.pseudo()
の関係を示しています。
js
const myElement = document.querySelector("q");
const cssPseudoElement = myElement.pseudo("::after");
const originatingElement = cssPseudoElement.element;
console.log(myElement === originatingElement); // true を出力
console.log(myElement.parentElement === originatingElement); // false を出力
console.log(myElement.lastElementChild === cssPseudoElement); // false を出力
console.log(myElement.lastChild === cssPseudoElement); // false を出力
console.log(myElement.nextElementSibling === cssPseudoElement); // false を出力
console.log(myElement.nextSibling === cssPseudoElement); // false を出力
仕様書
Specification |
---|
CSS Pseudo-Elements Module Level 4 # dom-csspseudoelement-element |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
element |
Legend
Tip: you can click/tap on a cell for more information.
- No support
- No support
- Experimental. Expect behavior to change in the future.
- User must explicitly enable this feature.
The compatibility table on 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.