编辑下面的代码:【加编码】
<html> <head> <script src="https://libs.baidu.com/jquery/1.10.2/jquery.min.js"> </script> <script> function appendText() { var txt1="<p>Text.</p>"; // Create text with HTML var txt2=$("<p></p>").text("Text."); // Create text with jQuery var txt3=document.createElement("p"); txt3.innerHTML="Text."; // Create text with DOM $("body").append(txt1,txt2,txt3); // Append new elements } </script> </head> <body> <p>This is a paragraph.</p> <button onclick="appendText()">Append text</button> </body> </html>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂