Attr.prefix read-only property returns the namespace prefix of the specified attribute, or null if no prefix is specified.

Before DOM4 this API was defined within the 节点 接口。

句法

string = attribute.prefix
					

范例

The following logs "x" to the console.

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

注意事项

This will only work when a namespace-aware parser is used, i.e. when a document is served with an XML MIME type. This will not work for HTML documents.

规范

规范 状态 注释
DOM
The definition of 'Attr: prefix' in that specification.
实时标准
DOM4
The definition of 'Attr.prefix' in that specification.
过时

浏览器兼容性

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. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
prefix Chrome 46
46
This API was previously available on the 节点 API。
Edge ≤18 Firefox 48
48
This API was previously available on the 节点 API。
IE No Opera 33
33
This API was previously available on the 节点 API。
Safari 1.3 WebView Android 46
46
This API was previously available on the 节点 API。
Chrome Android 46
46
This API was previously available on the 节点 API。
Firefox Android 48
48
This API was previously available on the 节点 API。
Opera Android 33
33
This API was previously available on the 节点 API。
Safari iOS 1 Samsung Internet Android 5.0
5.0
This API was previously available on the 节点 API。

图例

完整支持

完整支持

不支持

不支持

见实现注意事项。

另请参阅

元数据

  • 最后修改: