把html相关的代码相连成一个字符串,赋给一个变量,innerhtml语法就可以了 比如 html 代码 <p id="p1">i would like to say: </p> var s = "<b>hello</b>"; document.getelementbyid("p1").innerhtml += s 结果 <p id="p1">i would like to say: <b>hello</b></p> 还有一些dom方法也可以实现 append等等
把html相关的代码相连成一个字符串,赋给一个变量, innerHTML 语法就可以了 比如 html 代码 I would like to say: var s = " Hello "; document. getElementById ("p1").innerHTML += s 结果 I would like to say: Hello 还有一些dom方法也可以实现 append等等