You are developing a web form that includes the following code.
When a user selects the check box, an input text box must be added to the page dynamically.
You need to ensure that the text box is added.
Which function should you use?
Explanation:
The appendChildmethod establishes a father-child relationship between two nodes. If the father node has
children already, the new child will be appended asthe last one, and hence can be accessed via the lastChild
method. When calling the appendChild, the child node is specified as the method’s parameter:
fatherObj.appendChild(childObj);
The applyElementmethod connects a child to its target father, which has been stripped down from its existing
children and father. When calling the applyElement method, the father node is specified as the method’s
parameter:
childObj.applyElement(fatherObj);