在javascript
沒有庫這是一個分解:
referencenode:之後我們要插入新的node。如果引用是最後一個孩子,則次要的賓語將為null。 insertBefore handles this case by adding the new node to the end of the list.
Reusable Function
We can wrap this functionality in a reusable function:
referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);這將使用文本“ test”創建一個新的跨度元素,並在DIV元素之後插入ID“ foo”。
免責聲明: 提供的所有資源部分來自互聯網,如果有侵犯您的版權或其他權益,請說明詳細緣由並提供版權或權益證明然後發到郵箱:[email protected] 我們會在第一時間內為您處理。
Copyright© 2022 湘ICP备2022001581号-3