Professional Documents
Culture Documents
Javascript DOM Cheatsheet
Javascript DOM Cheatsheet
node.previousSibling: Retrieves the previous sibling node and Known browser quirks:
stores it as an object.
getAttribute and setAttribute are not reliable. Instead, assign
node.nextSibling: Retrieves the next sibling node and stores it the property of the element object directly: obj.property = value.
as an object. Furthermore, some attributes are actually reserved words, so instead
node.childNodes: Retrieves all child nodes of the object and of class use className and instead of for use HTMLfor.
stores them in an list. here are shortcuts for the first and last child Real DOM compliant browsers will return linebreaks as text nodes in
node, named node.firstChild and node.lastChild. the childNodes collection, make sure to either remove them or test
node.parentNode: Retrieves the node containing node. for the nodeType.
Assembled by Christian Heilmann (http://wait-till-i.com), licensed Creative Commons Attribution (http://creativecommons.org/licenses/by/3.0/). Enjoy.