<form action="#">
<p>
<input type="button" value="顔アイコン1" onclick="fInsertBefore('emoticon117')" />
<input type="button" value="顔アイコン2" onclick="fInsertBefore('good4')" />
<input type="button" value="顔アイコン3" onclick="fInsertBefore('android11')" />
</p>
</form>
<div id="resInsertBefore">←ここにアイコンが挿入されますよ</div>
<script type="text/javascript">
function fInsertBefore(iconName){
/* 親ノード */
var parentObj=document.getElementById("resInsertBefore");
/* IMG要素生成 */
var iconObj=document.createElement("IMG");
/* IMG要素のsrc属性を設定 */
iconObj.setAttribute("src", "/content/img/icon/material-design/png/"+iconName+".png");
iconObj.setAttribute("width",32);
iconObj.setAttribute("height",32);
/* 親ノードの子ノードの先頭にIMG要素を挿入 */
parentObj.insertBefore(iconObj, parentObj.lastChild);
}
</script>