开发者

Javascript Alternative to appendChild

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()

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜