JSFiddle - React, Tailwind, and code Playground
HTML
<div id="smiley-box">
</div>
JavaScript
// create the anchor, set it's onclick
var para=document.createElement("a");
para.href = "#";
para.onclick = function() {
insert_text('[img]imagesourcelocation[/img]' ,true);
return false;
}
// create the img and set it's src
var node=document.createElement("img");
node.src = "http://upload.wikimedia.org/wikipedia/commons/thumb/8/80/Smiley.png/50px-Smiley.png"
// add the img to the anchor
para.appendChild(node);
// add the anchor to the div
var element=document.getElementById("smiley-box");
element.appendChild(para);