I want to insert a node as a child node (element node ) at 开发者_运维知识库a fixed position(0) i.e. it should replace a child node (if there is one) and not append..
Which function should I use to ensure crossbrowser compatiblity?
Test to see if the element has a firstChild
. If it has one, use replaceChild
otherwise use appendChild
Select the child and use .replaceWith()
精彩评论