Append multiple items in JavaScript

后端 未结 9 398
长情又很酷
长情又很酷 2020-12-07 20:58

I have the following function and I am trying to figure out a better way to append multiple items using appendChild().

When the user clicks on Add, each

9条回答
  •  离开以前
    2020-12-07 21:47

    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,listItemLabel,editButton,deleteButton);
    

提交回复
热议问题