HTML DOM
The read-only htmlFor property of the HTMLOutputElement returns a live DOMTokenList object containing a list of ids of those elements contributing input values to (or otherwise affected) the calculation. It reflects the output element's for content attribute.
Value
A live DOMTokenList object.
Although the htmlFor property itself is read-only in the sense that you can't replace the DOMTokenList object, you can still assign to the htmlFor property directly, which is equivalent to assigning to its DOMTokenList/value property. You can also modify the DOMTokenList object using the DOMTokenList/add, DOMTokenList/remove, DOMTokenList/replace, and DOMTokenList/toggle methods.
Examples
const outputElem = document.getElementById("result");
for (const id of outputElem.htmlFor) {
const elem = document.getElementById(id);
elem.style.outline = "2px solid red";
}
Specifications
Browser compatibility
See also
- output
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
