Skip to content

HTML & DOM

Brandon Jordan edited this page Sep 7, 2025 · 9 revisions

Element

createElement(...elements);

Creates and returns an HTML element. Appends elements to the created element.

createElement(
    createElement(),
);

It can also contain objects for the configuration of the element, either containing attributes or properties.

createElement({tag: "button"}, text("Button Text"));

Text Node

Shorthand creates an HTML text node.

text(string);

Sanitize HTML

Remove any script tags from an HTML string.

sanitizeHTML("<script>console.log(\"hacked!\");</script>")

Unescape HTML

Returns an HTMLElement containing unescaped and sanitized HTML (script tags removed).

unescapeHTML("<script>console.log(\"hacked!\");</script><div>Just some HTML code. :-)</div>");

Tag Name

Get the element tag name in lowercase.

tagName(element);

Is Input Element

Check if an element accepts text input.

inputTag(element);

Get element selector

Generate a selector for an element based on ID and class.

getSelector(element);

Lazy Image

Create an image element that will lazy load the image when appended. attrs is passed to an element() function.

lazyImage(src, attrs = {});
Clone this wiki locally