https://www.w3schools.com/js/tryit.asp?filename=tryjs_change_innerhtml
received: function(data) {
// Called when there‘s incoming data on the websocket for this channel
// document.getElementById("notifications").innerHTML = data.html;
// ??的只是取代,不能增加节点,我像知道如何增加子节点。
$("#notifications").prepend(data.html);
}
如何用原生js写出$("#notifications").prepend(data.html);
备注:ActionCable.server.broadcast "notifications:11",
{html: "<div>Hello world</div>"}
原文:https://www.cnblogs.com/chentianwei/p/9307281.html