how to create html element dynamically in javascript

var itemManCnt=2; function addMoreHomeImage() { if(itemManCnt==6) { alert(“You can upload only 5 files”); return false; } var parentObj=document.getElementById(‘FileElementItem’); var divClrBoth = document.createElement(“div”); divClrBoth.setAttribute(“class”,”ClrBoth”); divClrBoth.setAttribute(“id”,itemManCnt); var divClrSelect = document.createElement(“div”); divClrSelect.setAttribute(“class”,”Select”); var file= document.createElement(“input”); file.setAttribute(“type”,”file”); file.setAttribute(“id”,”InsuranceHomeImage”+itemManCnt); file.setAttribute(“name”,”InsuranceHomeImage”+itemManCnt); divClrSelect.appendChild(file); var divRemove= document.createElement(“div”); divRemove.setAttribute(“class”,”AddNew”);