1 <!DOCTYPE html>
2 <html><!--树根-->
3
4 <head>
5 <meta charset="utf-8">
6 <meta http-equiv="X-UA-Compatible" content="IE=edge">
7 <title>Test</title>
8 <script type="text/javascript" src="/javascript/example.js"></script>
9 <meta name="description" content="An interactive getting started guide for Brackets.">
10 </head>
11 <body>
12 <script type="text/javascript">
13 insertParagraph("This is inserted.");
14 </script>
15 <div id="testDiv">
16 <p>This is <em>my</em> content.</p>
17 </div>
18 </body>
19 </html>
1 function insertParagraph(text) {
2 var str = "<p>";
3 str += text;
4 str += "</p>"
5 document.write(str);
6 }
7 window.onload = function() {
8 var para = document.createElement("p");
9 var testDiv = document.getElementById("testDiv");
10 testDiv.appendChild(para);
11 var text = document.createTextNode("Hello world");
12 para.appendChild(text);
13 }