.before(...siblings)
Available on: InDom, InDomArrayInserts one or more HTML strings, DOM elements or InDom objects before the underlying element(s).Parameters:
If an argument is a string, it’s parsed as HTML and inserted. Sanitize untrusted strings before passing them.Examples:
...siblings {(string | Node | InDom)[]} - Content to append (variadic; single array is flattened)
Returns: {InDom | InDomArray} - this for chainingThrows: Error - If the underlying element(s) has been removed
Note: If an argument is a string, it’s parsed as HTML and inserted. Sanitize untrusted strings before passing them.Examples:
// before examples (mirror of after examples)
const ul = $1('ul.example-1');
const firstLi = $1(">li", ul);
firstLi.before('<div>test</div>'); // raw HTML string
firstLi.before(img); // native DOM element
firstLi.before($n(img)); // same img, in InDom object
firstLi.before($a('>div', donor)); // InDomArray (moves both divs)
$a('>li', ul).before('<span>test</span>'); // bulk before to every <li> of ulNext: setHtml »