Create a new instance of the HTML class.
The HTML element to be created or classified from.
The HTML element referenced in this instance. Change using .swapRef(), or remove using .cleanup().
.swapRef()
.cleanup()
Append an element. Typically used as a .append(new HTML(...)) call.
.append(new HTML(...))
The element to append.
HTML
Append multiple elements. Typically used as a .appendMany(new HTML(...), new HTML(...) call.
.appendMany(new HTML(...), new HTML(...)
Rest
The elements to append.
Append this element to another element. Uses appendChild() on the parent.
appendChild()
Element to append to. HTMLElement, HTML, and string (as querySelector) are supported.
Set attributes (object method.)
The attributes to set (as an object of key: value;)
key: value;
Toggle on/off a class.
The class to toggle.
Toggles OFF a class.
The class to disable.
Toggles ON a class.
The class to enable.
Safely remove the element. Can be used in combination with a .swapRef() to achieve a "delete & swap" result.
Clear the innerHTML of the element.
Retrieve HTML content from the element.
string
Retrieve text content from the element. (as innerText, not trimmed)
Retrieve the value of the element. Only applicable if it is an input or textarea.
input
textarea
Sets the text of the current element.
The text to set to.
Sets the ID of the element.
The ID to set.
Apply an event listener.
The event listener type to add.
The event listener callback to add.
Prepend an element. Typically used as a .prepend(new HTML(...)) call.
.prepend(new HTML(...))
The element to prepend.
Prepend multiple elements. Typically used as a .prependMany(new HTML(...), new HTML(...) call.
.prependMany(new HTML(...), new HTML(...)
The elements to prepend.
An easier querySelector method.
The string to query
a new HTML
An easier querySelectorAll method.
querySelector something.
The query selector.
The HTML element (not as HTML)
Apply CSS styles (dashed method.) Keys use CSS syntax, e.g. background-color.
background-color
The styles to apply (as an object of key: value;.)
Apply CSS styles (JS method.) Keys use JS syntax, e.g. backgroundColor.
backgroundColor
The styles to apply (as an object of key: value;)
Swap the local elm with a new HTMLElement.
elm
The element to swap with.
Remove an event listener.
The event listener type to remove.
The event listener callback to remove.
Set the text value of the element. Only works if element is input or textarea.
The value to set.
Static
An alternative method to create an HTML instance.
Element to create from.
Generated using TypeDoc
Create a new instance of the HTML class.