There seems to be some confusion here, so I'll summarize:
On the document
object, there are a number of methods you can use to locate an element:
document.getElementById('myid');
will return a single DOM element (if it exists) with an id
attribute equal to myid
.
document.getElementsByName('myname');
will return an array of DOM elements with a name
attribute equal to myname
.
document.getElementsByTagName('div');
will return an array of DOM elements with a matching tag - in this case, all div
s in the document.
The case is important.
Does that clear things up?
This should work with all browsers provided you're not trying to get elements inside an iframe or something like that, but if you're having trouble with different browsers, I'd suggest using something like jQuery. It abstracts the browser differences from you so you can use the same syntax regardless of the browser being used.