Skip to content

Function: writeHTML() ​

Overload 1 ​

writeHTML(element, html): void

Defined in: dom.ts:144

Sets the HTML content of the given element.

Parameters ​

element ​

HTMLElement

The target element.

html ​

string

The HTML string to write.

Returns ​

void

Example ​

ts
// HTML
<div id="container"></div>
// JS
const el = facile.getElement('#container');
facile.writeHTML(el, '<p>Hello!</p>');

Overload 2 ​

writeHTML<K>(tag, html): void

Defined in: dom.ts:157

Sets the HTML content of the first element matching the given tag name. Does nothing if no element is found.

Type Parameters ​

K ​

K extends keyof HTMLElementTagNameMap

Parameters ​

tag ​

K

The HTML tag name to search for.

html ​

string

The HTML string to write.

Returns ​

void

Example ​

ts
// HTML
<div></div>
// JS
facile.writeHTML('div', '<p>Hello!</p>');

Overload 3 ​

writeHTML(selector, html): void

Defined in: dom.ts:170

Sets the HTML content of the first element matching the given CSS selector. Does nothing if no element is found.

Parameters ​

selector ​

string

A CSS selector string.

html ​

string

The HTML string to write.

Returns ​

void

Example ​

ts
// HTML
<div id="container"></div>
// JS
facile.writeHTML('#container', '<p>Hello!</p>');