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. |
过时 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
prefix
|
Chrome
46
|
Edge ≤18 |
Firefox
48
|
IE No |
Opera
33
|
Safari 1.3 |
WebView Android
46
|
Chrome Android
46
|
Firefox Android
48
|
Opera Android
33
|
Safari iOS 1 |
Samsung Internet Android
5.0
|
完整支持
不支持
见实现注意事项。
Attr
localName
namespaceURI
prefix
AbortController
AbortSignal
AbstractRange
ByteString
CDATASection
CSSPrimitiveValue
CSSValue
CSSValueList
CharacterData
ChildNode
注释
CustomEvent
DOMConfiguration
DOMError
DOMErrorHandler
DOMException
DOMImplementation
DOMImplementationList
DOMImplementationRegistry
DOMImplementationSource
DOMLocator
DOMObject
DOMParser
DOMPoint
DOMPointInit
DOMPointReadOnly
DOMRect
DOMString
DOMTimeStamp
DOMTokenList
DOMUserData
Document
DocumentFragment
DocumentType
元素
ElementTraversal
Entity
EntityReference
事件
EventTarget
HTMLCollection
MutationObserver
节点
NodeFilter
NodeIterator
NodeList
NonDocumentTypeChildNode
ProcessingInstruction
PromiseResolver
范围
StaticRange
文本
TextDecoder
TextEncoder
TimeRanges
TreeWalker
TypeInfo
USVString
UserDataHandler
XMLDocument