JSFiddle - React, Tailwind, and code Playground
by bogdan_vq
HTML
<div id="my-container"></div>
JavaScript
// get a reference to the preexisting 'my-container' Element node
var myContainer = window.document.getElementById('my-container');
// create an <a> Element node
var myAnchor = window.document.createElement('a');
// create an href Attribute node
var myHref = window.document.createAttribute('href');
myHref.nodeValue = 'http://www.linkedin.com';
// create a Text node
var myText = window.document.createTextNode('LinkedIn');
// compose the nodes
myAnchor.setAttributeNode(myHref)
myAnchor.setAttribute('title', 'Go to LinkedIn');
myAnchor.appendChild(myText);
myContainer.appendChild(myAnchor);
var s = '';
s += 'window.document.nodeType: ' + window.document.nodeType + '\n';
s += 'myAnchor.nodeType: ' + myAnchor.nodeType + '\n';
s += 'myHref.nodeType: ' + myHref.nodeType + '\n';
s += 'myText.nodeType: ' + myText.nodeType + '\n';
alert(s);