Append versus appendTo and appendChild
- 2020-03-30 01:05:10
- OfStack
Append () is preceded by the object to be selected, followed by the contents of the element to be inserted into the object
AppendTo () is preceded by the contents of the element to be inserted and is a Jquery object, followed by the object to be selected
Example:
$(' # a '). Append (" content ");
$(' < Div> Content< / div> '). AppendTo ($(' # a '));
AppendTo must be preceded by a Jquery object.
AppendChild (Node) this method typically adds a Node after the last child of the specified element Node
However, if Node is a DOM object in the page, you either add the Node or simply Move the Node.
AppendChild you can think of as moving an element. If you want a copy of the past, make clone first
AppendTo () is preceded by the contents of the element to be inserted and is a Jquery object, followed by the object to be selected
Example:
$(' # a '). Append (" content ");
$(' < Div> Content< / div> '). AppendTo ($(' # a '));
AppendTo must be preceded by a Jquery object.
AppendChild (Node) this method typically adds a Node after the last child of the specified element Node
However, if Node is a DOM object in the page, you either add the Node or simply Move the Node.
AppendChild you can think of as moving an element. If you want a copy of the past, make clone first