首页 > 其他分享 >js 插入节点

js 插入节点

时间:2023-01-21 14:11:09浏览次数:44  
标签:insertBefore sp2 nextSibling js 插入 null 节点

apendChild

element.appendChild(aChild)
如果 sp2 没有下一个节点,则它肯定是最后一个节点,则 sp2.nextSibling 返回 null,且 sp1 被插入到子节点列表的最后面(即 sp2 后面)。

insertBefore

parent.insertBefore(childNew, sp2.nextSibling);
如果 sp2 没有下一个节点,则它肯定是最后一个节点,则 sp2.nextSibling 返回 null,且 sp1 被插入到子节点列表的最后面(即 sp2 后面)。    
https://developer.mozilla.org/zh-CN/docs/Web/API/Node/insertBefore

标签:insertBefore,sp2,nextSibling,js,插入,null,节点
From: https://www.cnblogs.com/sqmw/p/17063764.html

相关文章