let nodeCounter = 1; function addChild() { let p = document.createElement("p"); p.setAttribute('class', 'pnode'); p.innerHTML = `new node created #${nodeCounter}`; document.getElementById("div1").appendChild(p); nodeCounter++; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter