JavaScriptをやっている絵

【JavaScript Tips】Simply set multiple attributes to the created element

【JavaScript Tips】Simply set multiple attributes to the created element

JavaScriptをやっている絵
オレンジ

from

   const input = document.createElement('input');
   input.setAttribute("id", "1");
   input.setAttribute("type", "button");
   input.setAttribute("value", "delete");
.
.
.

to

   const input = document.createElement('input');
   const setInput = Object.assign(input, {type: "button", value: "delete", id: `${id}`, onclick: () => {}}