Creating, Appending, and Inserting Elements and TextNodes
In this example we will use:
- document.createElement("a tag like h1, p, ol, li")
- document.createTextNode("some text")
- element.appendChild("an element")
- element.insertBefore("an element")
View this page in jsbin and uncomment these lines of JavaScript:
- 8 to see new heading 1
- 15 to see new paragraph
- 29 to see new ordered list with one item
- 39 to see ordered list populated from array
- 49 to insert new item at the top of the list