replaceChildren
The replaceChildren
method replaces the element's children with new content.
Syntax
element.replaceChildren(content);
element.replaceChildren(content, options);
Parameters
content
: string- The content to replace the element's children with.
options
: ElementRewriterOptions- An optional object that can have the following properties:
escapeHTML
: boolean- If
true
, any HTML markup incontent
will be escaped so it is safe to insert as text.
- If
- An optional object that can have the following properties:
Examples
// Assuming `e` is an Element representing <div>Hello</div>
e.replaceChildren("Greetings!");
// Result: <div>Greetings!</div>