Element: prefix property

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

Thuộc tính Element.prefix là thuộc tính chỉ đọc trả về the namespace prefix of the specified element, or null if no prefix is specified.

Giá trị

Một chuỗi.

Ví dụ

Các giá trị sau logs "x" to the console.

xml
<x:div onclick="console.log(this.prefix)"/>

Notes

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.

Đặc tả kỹ thuật

Thông số kỹ thuật
DOM
# ref-for-dom-element-prefix①

Trình duyệt hỗ trợ

Xem thêm