DOM

<< Click to Display Table of Contents >>

Navigation:  Navigation >

DOM

Each element in a DOM tree have the following properties

 

Parent - parent node or nil

Count - number of child elements

Elements[index] - child elements

Attributes[index] - attributes

Attributes.Count - number of attributes (check Attributes for nil!)

 

Adding new elements

 

function Add(const E: TElement): TElement  

 Add E to child elements
function InsertAfter(const EAfter, E: TElement): TElement 

 Insert E after EAfter element. EAfter should be child of current element.
function InsertBefore(const EBefore, E: TElement): TElement 

 Insert E before EBefore element. EBefore should be child of current element.
function AppendChild(const E: TElement): TElement 

 Append E to child elements
function AddHTML(const HTML: hstring): THtmlNode 

 Add HTML
function InsertHTML(const HTML: hstring): THtmlNode - 

 Insert HTML at top

 

Deleting element

 

procedure DeleteChild(const E: THtNode); 

 

Updating elements

 

To change whole element content use InnerHtml and OuterHTML properties.

 

Note that DOM modifications will not be displayed in control until Repaint is called (f.e. HtPanel1.Repaint).