Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

difference between .append and .appendChild

.append()
This method is used to add an element in form of a Node object or a DOMString (basically means text).

.appendChild()
Similar to the .append method, this method is used to elements in the DOM, but in this case, only accepts a Node object.

--Differences--
1).append accepts Node objects and DOMStrings while .appendChild accepts only Node objects
2).append does not have a return value while .appendChild returns the appended Node object
3).append allows you to add multiple items while appendChild allows only a single item
Source by dev.to #
 
PREVIOUS NEXT
Tagged: #difference
ADD COMMENT
Topic
Name
6+4 =