jQuery append() vs appendChild()不再
2022-08-30 05:20:16
下面是一些示例代码:
function addTextNode(){
var newtext = document.createTextNode(" Some text added dynamically. ");
var para = document.getElementById("p1");
para.appendChild(newtext);
$("#p1").append("HI");
}
<div style="border: 1px solid red">
<p id="p1">First line of paragraph.<br /></p>
</div>
和 有什么区别?
任何实时场景?append()
appendChild()