<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>无标题文档</title> <style type="text/css"> .message{ width:200px; height:100px; color:blue; background-color:#CCC;} </style> </head> <body> <script type="text/javascript"> var pNode = document.createElement("p"); var textNode = document.createTextNode("I love JavaScript!");//另外这个方法可以不传参数吗 pNode.className = "message"; //textNode.innerHTML = "I love JavaScript";//上面不传参,用这个但没用 document.body.appendChild(pNode.appendChild(textNode)); </script> </body> </html>
stone310
去看天荒地老