DOM Overview

Key Element Properties

nodeName
nodeType
tagName
style
innerHTML
textContent
 
parentElement
parentNode
childElementCount
 
children
childNodes (All child nodes)
 
firstElementChild
firstChild
 
lastElementChild
lastChild
 
previousElementSibling
previousSibling
 
nextElementSibling
nextSibling
 
appendChild
removeChild
replaceChild
insertBefore
 
attributes
getAttribute
hasAttribute
setAttribute
 

Usage Notes

Get Element By Id
elem = document.getElementById('list_1')
elem = document.querySelector('#list_1')
Get Child Element
obj = elem.children.item(0)
obj = elem.querySelector('LI')
Get Child Elements
objs = elem.querySelectorAll('LI')
objs = elem.getElementsByTagName('LI')
objs = elem.getElementsByClassName('ListItem')
Append Child Item
obj = document.createElement('DIV')
txt = document.createTextNode(text)
elem.appendChild(obj);
Insert Child Item
obj = document.createElement('DIV')
txt = document.createTextNode(text)
elem.insertBefore(obj, child-elem);
Remove List Item
elem.removeChild(child-elem);