Append multiple items in JavaScript

后端 未结 9 420
长情又很酷
长情又很酷 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:41

    I would like to add that if you want to add some variability to your html, you can also add variables like this:

    let node = document.createElement('div');
    node.classList.add("some-class");
    node.innerHTML = `
    ${myObject.title}
    ${myObject.subtitle}
    `;

提交回复
热议问题