In this case, document.getElementById('id1').appendChild(document.getElementById('id2'));
should do the trick.
More generally you can use insertBefore()
.
More Related Contents:
- How do I check if an element is hidden in jQuery?
- Why does jQuery or a DOM method such as getElementById not find the element?
- How do I set/unset a cookie with jQuery?
- jQuery .live() vs .on() method for adding a click event after loading dynamic html
- Creating a new DOM element from an HTML string using built-in DOM methods or Prototype
- Executing elements inserted with .innerHTML
- How can I select an element by name with jQuery?
- Difference between innerText, innerHTML and value?
- getElementsByTagName() equivalent for textNodes
- Event handlers inside a Javascript loop – need a closure?
- jQuery object and DOM element
- Javascript get XPath of a node
- How to resolve the C:\fakepath?
- Javascript – Are DOM redraw methods synchronous?
- How to check if an embedded SVG document is loaded in an html page?
- Finding DOM node index
- Dynamic creation of table with DOM
- jQuery events .load(), .ready(), .unload()
- Adding an img element to a div with javascript
- Remove specific HTML tag with its content from javascript string
- Is it possible to programmatically catch all events on the page in the browser?
- Is there any way to accelerate the mousemove event?
- How do I wrap a text selection from window.getSelection().getRangeAt(0) with an html tag?
- Inject CSS stylesheet as string using Javascript
- JavaScript: Is it better to use innerHTML or (lots of) createElement calls to add a complex div structure? [duplicate]
- Getting the text from a drop-down box
- Accessing a DOM object defined in an external SVG file
- In JavaScript, how can I replace text in an HTML page without affecting the tags?
- How do I manipulate the SVG DOM and create elements?
- Removing element with jQuery?