ProcessingInstruction: hasAttributes() method
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Want more browser support for this feature? Tell us why.
Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The hasAttributes() method of the ProcessingInstruction
interface returns a boolean value indicating whether the current element has any
attributes or not.
Syntax
js
hasAttributes()
Parameters
None.
Return value
A boolean.
Examples
>Basic usage
js
const pi = document.createProcessingInstruction("start", 'name="placeholder"');
const pi2 = document.createProcessingInstruction("start", "");
console.log(pi.hasAttributes());
console.log(pi2.hasAttributes());
// logs:
// true
// false
Specifications
| Specification |
|---|
| DOM> # dom-processinginstruction-hasattributes> |