const pi = document.createProcessingInstruction(
"start",
'name="placeholder" more="info"',
);
console.log(pi.getAttributeNames());
// logs:
// ['name', 'more']
// Iterate over processing instruction's attributes
for (const name of pi.getAttributeNames()) {
const value = pi.getAttribute(name);
console.log(name, value);
}
// logs:
// name placeholder
// more infoProcessingInstruction: getAttributeNames() method
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.