PP.removeChildren

Syntax

removeChildren(element: HTMLElement);

Parameters

element. DOM tree with child nodes to delete.

Description

The removeChildren method removes all children in a specified DOM tree.

Example

To execute the example, add a link to PP.js scenario file to HTML page. Create a DOM tree based on a specified string containing HTML markup, and remove all its children:

// Determine markup string
var markup = "<div><p class='plainText'>12</p><span class='plainText'>abc</span></div>";
// Transform markup to DOM node
var dom = PP.htmlToDOM(markup, False);
console.log("Source tree markup: " + dom.outerHTML);
// Remove all child nodes in the specified tree
PP.removeChildren(dom);
// Get HTML markup of the obtained tree
console.log("Markup of the obtained tree: " + dom.outerHTML);

After executing the example the browser console displays DOM tree markup before and after all its child nodes are deleted:

Markup of the source tree: <div><p class="plainText">12</p><span class="plainText">abc</span></div>
Markup of the resulting tree: <div></div>

See also:

PP