Posts

Showing posts with the label Appendchild

Append Multiple Items In JavaScript

Answer : You can do it with DocumentFragment. var documentFragment = document.createDocumentFragment(); documentFragment.appendChild(listItem); listItem.appendChild(listItemCheckbox); listItem.appendChild(listItemLabel); listItem.appendChild(editButton); listItem.appendChild(deleteButton); listElement.appendChild(documentFragment); DocumentFragments allow developers to place child elements onto an arbitrary node-like parent, allowing for node-like interactions without a true root node. Doing so allows developers to produce structure without doing so within the visible DOM You can use the append method in JavaScript. This is similar to jQuery's append method but it doesnot support IE and Edge. You can change this code listElement.appendChild(listItem); listItem.appendChild(listItemCheckbox); listItem.appendChild(listItemLabel); listItem.appendChild(editButton); listItem.appendChild(deleteButton); to listElement.append(listItem,listItemCheckbox,listItemLa...