Using the "beforeend" value:
Click the button to insert the red span inside the header:
<!DOCTYPE html> <html> <body> <p>This method inserts a specified element, into a specified position.</p> <span style="color:red">My span</span> <h2 id="myH2">My Header</h2> <button onclick="myFunction()">Move span</button> <script> function myFunction() {/*ww w.ja va 2 s.c o m*/ var s = document.getElementsByTagName("span")[0]; var h = document.getElementById("myH2"); h.insertAdjacentElement("beforeend", s); } </script> </body> </html>