xxxxxxxxxx
<!DOCTYPE html>
<html>
<title>jQuery - append()插入多个元素示例 - 基础教程(div.cn)</title>
<head>
<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
appendText();
});
});
function appendText() {
let x = "<p>示例文本.</p>";
let y = $("<p></p>").text("示例文本.");
let z = document.createElement("p");
z.innerHTML = "示例文本.";
$("body").append(x, y, z);
}
</script>
</head>
<body>
<p>单击下面的按钮:</p>
<button>插入多个元素</button>
</body>
</html>