DOM
The hasAttributes() method of the ProcessingInstruction
interface returns a boolean value indicating whether the current element has any
attributes or not.
Syntax
hasAttributes()
Parameters
None.
Return value
A boolean.
Examples
Basic usage
const pi = document.createProcessingInstruction("start", 'name="placeholder"');
const pi2 = document.createProcessingInstruction("start", "");
console.log(pi.hasAttributes());
console.log(pi2.hasAttributes());
// logs:
// true
// false
Specifications
Browser compatibility
See also
- ProcessingInstruction.hasAttribute()
- ProcessingInstruction.getAttribute()
- ProcessingInstruction.getAttributeNames()
- ProcessingInstruction.setAttribute()
- ProcessingInstruction.removeAttribute()
- ProcessingInstruction.toggleAttribute()
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
