[nycphp-talk] more on document.getElementById("Div" + count)
Rahmin Pavlovic
rahmin at insite-out.com
Wed Aug 2 15:43:20 EDT 2006
Bob,
I haven't peeped the JS source, but in general, it's good form to test if
your objects and properties exist before referencing them.
For example, the error you're receiving basically says the element you're
trying to access isn't there. This can be solved by simply checking for it:
var myElement=document.getElementById("Div" + count);
if(myElement) {
// do something with, to or on myElement
}
It's good do this sorta thing in any language, but even more so in JS where
the syntax is (still) browser-dependant (despite being more DOM-oriented
these days).
More information about the talk
mailing list