1 <!doctype html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>Document</title> 6 </head> 7 <body> 8 <div> 9 10 </div> 11 <script> 12 div = document.createElement(‘div‘); 13 div.innerHTML=‘这是新创建的div‘; 14 div.style.backgroundColor=‘pink‘; 15 document.body.appendChild(div); 16 </script> 17 </body> 18 </html>
创建节点document.createElement('div')案例
原文:https://www.cnblogs.com/ustc-yy/p/12073292.html