From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/zh-cn/web/api/attr/prefix/index.html | 67 ++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 files/zh-cn/web/api/attr/prefix/index.html (limited to 'files/zh-cn/web/api/attr/prefix') diff --git a/files/zh-cn/web/api/attr/prefix/index.html b/files/zh-cn/web/api/attr/prefix/index.html new file mode 100644 index 0000000000..16215636ec --- /dev/null +++ b/files/zh-cn/web/api/attr/prefix/index.html @@ -0,0 +1,67 @@ +--- +title: Attr.prefix +slug: Web/API/Attr/prefix +translation_of: Web/API/Attr/prefix +--- +
{{APIRef("DOM")}}
+ +

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

+ +
+

在 DOM4 之前此 API 被定义在 {{domxref("Node")}} 接口中。

+
+ +

语法

+ +
string = attribute.prefix
+
+ +

示例

+ +

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

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

注意

+ +

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

+ +

规范

+ + + + + + + + + + + + + + + + + + + + + +
规范状态备注
{{SpecName('DOM WHATWG', '#dom-attr-prefix', 'Attr: prefix')}}{{Spec2('DOM WHATWG')}}
{{SpecName("DOM4", "#dom-attr-prefix", "Attr.prefix")}}{{Spec2("DOM4")}}
+ +

浏览器兼容性

+ + + +

{{Compat("api.Attr.prefix")}}

+ +

参考

+ + -- cgit v1.2.3-54-g00ecf