Javascript create dynamic elements function

PHOTO EMBED

Wed Jul 01 2020 12:12:44 GMT+0000 (Coordinated Universal Time)

Saved by @peota #javascript

function createElement(type, attributes) {
  var element = document.createElement(type);
  for (var key in attributes) {
    if (key == "class") {
        element.classList.add.apply(element.classList, attributes[key]); // add all classes at once
    } else {
      element[key] = attributes[key];
    }
  }
  someElement.appendChild(element);
}
content_copyCOPY

https://stackoverflow.com/questions/43168284/javascript-createelement-function