The [[mdn>Web/API/HTMLElement|HTMLElement]] it was called on, thus allowing for command chaining.
Note:
This function parses the code as XHTML, which is much stricter than HTML and may throw an error if the code is incorrect. It also means that characters like ''%%<%%'' or ''%%>%%'' must be escaped as ''%%<%%'' and ''%%>%%'', unless they are used to indicate an XHTML element. If you do not need the parser function, the [[toolbox:element:appendtext:index|.appendText()]] and [[toolbox:element:prependtext:index|.prependText()]] functions are the better alternatives.
===== Examples =====
Simple example:
let foo = document.getElementById('foo');
foo.setHtml('Clickhere!');
===== See also =====
* [[toolbox:element:gethtml:index|.getHtml()]]
* [[toolbox:element:appendtext:index|.appendText()]]
* [[toolbox:element:prependtext:index|.prependText()]]
* [[toolbox:element:appendnew:index|.appendNew()]]
* [[toolbox:element:prependnew:index|.prependNew()]]
===== More information =====
* [[mdn>Web/API/DOMParser/parseFromString|DOMParser: parseFromString() method]] on MDN.
* [[mdn>Web/API/Element/innerHTML|Element: innerHTML property]] on MDN.