createElement,createTextNode,appendChild
<html> <head> <meta charset="UTF-8"> <title></title> <script> window.onload=function () { var div1=document.getElementById('div1'); var para=document.createElement('p'); var txt=document.createTextNode('hello word'); div1.appendChild(para); para.appendChild(txt); } </script> </head> <body> <div id="div1"> </div> </body> </html>

浙公网安备 33010602011771号