CSSPseudoElement: type 屬性

可用性有限

此特性不是基線特性,因為它在一些最廣泛使用的瀏覽器中不起作用。

實驗性: 這是一項實驗性技術
在生產中使用此技術之前,請仔細檢查瀏覽器相容性表格

typeCSSPseudoElement 介面的一個只讀屬性,它返回偽元素的型別,以字串形式表示,形式為 CSS 選擇器

包含以下值之一的字串:

示例

下面的例子演示了 CSSPseudoElement.typeElement.pseudo() 之間的關係

js
const myElement = document.querySelector("q");
const mySelector = "::after";
const cssPseudoElement = myElement.pseudo(mySelector);
const typeOfPseudoElement = cssPseudoElement.type;

console.log(mySelector === typeOfPseudoElement); // Outputs true

規範

規範
CSS 偽元素模組 Level 4
# dom-csspseudoelement-type

瀏覽器相容性

另見