✅javascript 语法:附加子节点

received: function(data) {

 $("#notifications").prepend(data.html);
}

 

如何用原生js写出jquery的功能:

先创建<div>节点,然后附加到需求元素的内部,然后改变这个<div>的innerHTML。

var p = document.createElement('div')

document.getElementById("notifications").appendChild(p)

document.getElementById("notifications").lastChild.innerHTML = data.html

posted @ 2018-07-13 20:30  Mr-chen  阅读(171)  评论(0编辑  收藏  举报