| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/en-US/docs/Web/API/ProcessingInstruction/getAttribute | [Back] [Original] |
Get to know MDN better
The getAttribute() method of the
ProcessingInstruction interface returns the value of a specified attribute on the
processing instruction.
If the given attribute does not exist, the value returned will be null.
getAttribute(attributeName)
attributeNameThe name of the attribute whose value you want to get.
A string containing the value of attributeName if the attribute exists; otherwise null.
Processing instruction arguments are case-sensitive.
HTML character references in an attribute's source markup (for example, <, &, or <) are decoded by the HTML parser when the document is parsed, so getAttribute() returns the decoded value, not the source.
For example:
const pi = document.createProcessingInstruction(
"start",
'data-payload="<b>hi</b>"',
);
pi.getAttribute("data-payload");
// <b>hi</b>
const pi = document.createProcessingInstruction("start", 'name="placeholder"');
console.log(pi.getAttribute("name"));
// Logs:
// "placeholder"
| Specification |
|---|
| DOM # dom-processinginstruction-getattribute |
ProcessingInstruction.hasAttribute()ProcessingInstruction.hasAttributes()ProcessingInstruction.getAttributeNames()ProcessingInstruction.setAttribute()ProcessingInstruction.removeAttribute()ProcessingInstruction.toggleAttribute()This page was last modified on Aug 13, 2026 by MDN contributors.
ProcessingInstructionAbortControllerAbortSignalAbstractRangeAttrCDATASectionCharacterDataCommentCustomEventDOMErrorDOMExceptionDOMImplementationDOMParserDOMTokenListDocumentDocumentFragmentDocumentTypeElementEventEventTargetHTMLCollectionMutationObserverMutationRecordNamedNodeMapNodeNodeIteratorNodeListQuotaExceededErrorRangeShadowRootStaticRangeTextTreeWalkerXMLDocumentXPathEvaluatorXPathExpressionXPathResultXSLTProcessorYour blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |