.......
function microTemplate(t , args){
return t.replace(/\$\$\{(.*?)\}/img , function(ag , ag1){
return args[ag1]||ag
})
}
var stringBuffer = []
var info = [{name:"aaa",placeholder:"aaa"},{name:"bbb",placeholder:"bbb"}]
var ilen = info.length
while(ilen--){
stringBuffer.push(microTemplate("<tr><td><input type='text' name='$${name}' placeholder='$${placeholder}'></td></tr>",info[ilen]))
}
stringBuffer.push("<tr><td><input type='submit' value='提交' /></td></tr>")
document.getElementsByTagName("table")[0].innerHTML=stringBuffer.join("")
试试吧,应该会优雅一点,模板只做个大概,正常的话可以找个前端模板引擎