CSSPseudoElement: thuộc tính element
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
Thuộc tính chỉ đọc element của giao diện CSSPseudoElement trả về tham chiếu đến phần tử gốc của pseudo-element, nói cách khác là phần tử cha của nó.
Giá trị
Một Element biểu thị phần tử gốc của pseudo-element.
Ví dụ
Ví dụ dưới đây minh họa mối quan hệ giữa CSSPseudoElement.element và Element.pseudo():
js
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
Thông số kỹ thuật
| Specification |
|---|
| CSS Pseudo-Elements Module Level 4> # dom-csspseudoelement-element> |