NN 6, IE 5
You want to derive a valid element object reference starting with the string ID or tag name of an existing element.
Use the W3C DOM method that has scope over every element in the document:
var elem = document.getElementById("elementID
");
If the element doesn’t have an id
attribute assigned to it, you can reach the element by tag name. The
following example retrieves an array of elements with the same tag
name:
var elems = document.getElementsByTagName("tagName
");
Assuming you know the position of the desired element among all elements with the same tag name, use standard array syntax to obtain a reference to the single element: