append 之后添加
    prepend 之前添加

    1. <!DOCTYPE html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
    6. <title>Document</title>
    7. </head>
    8. <body>
    9. <ul id="app">
    10. <li>html</li>
    11. </ul>
    12. <script>
    13. // append,prepend
    14. var app = document.getElementById("app");
    15. var p = "<h1>hello world<h1>";
    16. app.append(p);
    17. </script>
    18. </body>
    19. </html>

    1.PNG