Skip to content

Files

Latest commit

 

History

History
20 lines (14 loc) · 407 Bytes

prefer-dom-node-append.md

File metadata and controls

20 lines (14 loc) · 407 Bytes

Pattern: DOM node insertion via appendChild

Issue: -

Description

The append() method is more versatile than appendChild() as it can handle multiple nodes and both DOM nodes and strings in a single call.

Examples

Example of incorrect code:

foo.appendChild(bar);

Example of correct code:

foo.append(bar);
foo.append(textNode, elementNode, "text");