SOURCE

console 命令行工具 X clear

                    
>
console
window.onload=function(){
    var oDiv=document.createElement("div");
    var oP=document.createElement("p");
    var oText=document.createTextNode("Hi from dynamic DOM");
    oP.appendChild(oText);
    oDiv.appendChild(oP);
    var oP1=document.createElement("p");
    var oText1=document.createTextNode("second from dynamic DOM");
    oP1.appendChild(oText1);
    oDiv.appendChild(oP1);
    var oP2=document.createElement("p");
    var oText2=document.createTextNode("third from Dynamic DOM");
    oP2.appendChild(oText2);
    oDiv.appendChild(oP2);



document.body.appendChild(oDiv);

var oDiv1=document.createElement("div");
oDiv1.innerHTML="<p>Hi,innerHTML</p><p>the second innerHTML</p><p>the third innerHTML</p>";
document.body.appendChild(oDiv1);

console.log("oDiv's innerText:"+oDiv.innerText);
console.log("oDiv1's innerText:"+oDiv1.innerText);
}
<!DOCTYPE html> 
<html>
    <head>
        <meta charset="utf-8" />
        <title></title>
        <style type="text/css">
            
        </style>
        <script>
        
        </script>
    </head>
    <body>
        <button style="width:100px" data="button">测试</button>
    </body>
</html>