Attr.prefix

Attr.prefix 为只读属性,返回指定标签属性的名字空间前缀,如果没有前缀则返回 null

在 DOM4 之前此 API 被定义在 Node 接口中。

语法

string = attribute.prefix

示例

下例在控制台中输出“x”。

<div x:id="example" onclick="console.log(this.attributes[0].prefix)"/>

注意

该属性仅在使用有名字空间解析功能的解析器时有效,例如一个MIME类型为XML的文档。在HTML文档中无效。

规范

规范 状态 备注
DOM
Attr: prefix
Living Standard
DOM4
Attr.prefix
Obsolete

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
prefixChrome Full support 46
Notes
Full support 46
Notes
Notes This API was previously available on the Node API.
Edge Full support ≤18Firefox Full support 48
Notes
Full support 48
Notes
Notes This API was previously available on the Node API.
IE No support NoOpera Full support 33
Notes
Full support 33
Notes
Notes This API was previously available on the Node API.
Safari Full support 1.3WebView Android Full support 46
Notes
Full support 46
Notes
Notes This API was previously available on the Node API.
Chrome Android Full support 46
Notes
Full support 46
Notes
Notes This API was previously available on the Node API.
Firefox Android Full support 48
Notes
Full support 48
Notes
Notes This API was previously available on the Node API.
Opera Android Full support 33
Notes
Full support 33
Notes
Notes This API was previously available on the Node API.
Safari iOS Full support 1Samsung Internet Android Full support 5.0
Notes
Full support 5.0
Notes
Notes This API was previously available on the Node API.

Legend

Full support  
Full support
No support  
No support
See implementation notes.
See implementation notes.

参考