DOM JavaScript Cheat Sheet
I’ve just put together a small DOM cheatsheet for some developers here and thought why not share it and CC it in case it can be handy for you, too:
Click the screenshot or download the PDF version of the cheat sheet (85KB) here.



June 27th, 2007 at 1:14 pm
Nice Idea, but aren’t cheat sheets meant to be crammed with info and have a 3 pt font (that you can’t read at a glance) and have no white space. ;-) This one is none of those things.
June 27th, 2007 at 3:55 pm
Nice, but a few notes:
1.) using the object.property vs object.setAttribute() is NOT a wise move, and totally defeats the purpose of the DOM. .[get/set]Attribute() is cleaner, you just need to accomodate the fact that IE doesn’t follow the spec properly for things like class, for, name, frameborder, cellpadding, cellspacing etc.
Directly setting values on the object make your code look very 1995.
There should also be a note, that document.getElementById( id ) is broken in IE, and will also greedily return an element with a name matching the id specified.
June 27th, 2007 at 5:31 pm
@trevor: that is what I thought, too, but a recent survey on snook’s site made me change my mind, as it is about writing code that works as much as it is about following a standard (hey XMLhttpRequest is only a proposal, don’t use it!). In 1995 I wrote assembler, that didn’t look at all like this code.
As to IE’s greediness when it comes to name/id: This is a problem, but it also means you planned your page badly when you have an ID and name attribute with the same value on two different elements.
June 27th, 2007 at 7:00 pm
@trevor: The HTML DOM was standardized to ease the pain for HTML, so I’ve no problem using it. get/setAttribute may be more to the “spirit” of the DOM, but while IE sucks in that dept., no thanks.
BTW, it’s htmlFor, not HTMLfor. :)
June 28th, 2007 at 5:59 am
June 28th, 2007 at 9:13 am
June 28th, 2007 at 9:13 am
June 28th, 2007 at 9:38 am
I have question about this :
Real DOM compliant browsers will return linebreaks as text nodes in the childNodes collection, make sure to either remove them.
Is there an easy way to do that with a DOM method, i am looking how to do it with jquery too and YUI too
June 28th, 2007 at 6:57 pm
goetsu: I use this
July 6th, 2007 at 5:59 pm
Thanks for this Chris. I found it useful. An idea for an enhancement…you can put some simple functions on the back/2nd page…
July 9th, 2007 at 12:02 pm
July 9th, 2007 at 12:02 pm
DOM JavaScript Cheat Sheet
Listet DOM-Methoden auf, die in der Web-Entwicklung am häufigsten verwend [...]
July 9th, 2007 at 1:16 pm
July 9th, 2007 at 3:30 pm
July 9th, 2007 at 4:14 pm
July 10th, 2007 at 3:25 am
July 12th, 2007 at 3:42 am
DOM JavaScript Cheat Sheet
A small DOM cheatsheet with the most common DOM methods at a glance. [...]
July 12th, 2007 at 8:03 am
July 13th, 2007 at 11:34 am
July 27th, 2007 at 12:14 pm
July 29th, 2007 at 12:12 am
June 26th, 2008 at 2:56 am
@trevor, Using [set/get]Attribute makes your code look a lot like Java, which it’s not. It’s JavaScript, so use the features of the language that make it expressive and clean, like direct assignment to properties.
July 22nd, 2008 at 6:36 pm
Thanks for posting this. Just what I was looking for.