using javascript's .insertBefore to insert item as last child

前端 未结 6 1004
梦谈多话
梦谈多话 2020-12-18 01:15

I so miss jQuery. I\'m working on a project where I need to get my hands dirty with good \'ol plain Javascript again.

I have this scenario:

parent
           


        
6条回答
  •  生来不讨喜
    2020-12-18 02:00

    Also when not iterating through children (just inserting after referenceNode) this might be useful:

    parentNode.insertBefore(newNode, referenceNode.nextSibling);
    

提交回复
热议问题