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

type 只读特性在 CSSPseudoElement interface returns the type of the pseudo-element as a string, represented in the form of a CSS selector .

句法

var typeOfPseudoElement = cssPseudoElement.type;
					

A CSSOMString containing one of the following values:

范例

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

const myElement = document.querySelector('q');
const mySelector = '::after';
const cssPseudoElement = myElement.pseudo(mySelector);
const typeOfPseudoElement = cssPseudoElement.type;
console.log(mySelector === typeOfPseudoElement); // Outputs true
					

规范

规范 状态 注释
CSS Pseudo-Elements Level 4
The definition of 'type' 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
type 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.
不支持 63 — 75 Disabled
Disabled From version 63 until version 75 (exclusive): this feature is behind the dom.animations-api.getAnimations.enabled preference. To change preferences in Firefox, visit about:config.
不支持 47 — 63 Disabled
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 63 Disabled
63 Disabled
Disabled From version 63: this feature is behind the dom.animations-api.getAnimations.enabled preference. To change preferences in Firefox, visit about:config.
不支持 47 — 63 Disabled
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