阅读:3491回复:0
js动态append或appendChild添加的html()节点,显示是代码
错误演示:
var i = 0; i < 100; i++; let s = `<li class="chart-cont"><div class="chart-tittle">图表` + i + `标题:</div> </li>` let appendChartbox = document.getElementById("chart-cont-box") appendChartbox.append(s) 纠正: var i = 0; i < 100; i++; let s = `<li class="chart-cont"><div class="chart-tittle">图表` + i + `标题:</div> </li>` let objE = document.createElement("div") objE.innerHTML = s let appendChartbox = document.getElementById("chart-cont-box") appendChartbox.append(objE) |
|