The DOM Nodes Factory

The DOM node factory, somewhere by the Black Sea in Năvodari, Romania

Creating and deleting DOM Nodes

class DOMFactory {
// the next lines of code will be added here
static defaultNodeName = 'div';
static create(content = '', nodeName = DOMFactory.defaultNodeName) {
const el = document.createElement(nodeName)
el.innerText = content;
return el;
static delete(node) {
const parent = node.parentElement;

Example and source code



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store