GetElementsByID vs. GetElementByName [English]

The title is obviously wrong. Actually you must say GetElementByName and GetElementsByName. This is just logical, since an ID number can only exist once, or may only exist once, while a name can exist several times. That’s why GetElementsByName produces an Array, even if there is only one element with this name.

<!-- -->

document.getElementById("unentschlossen").align = wie;

<!-- -->

document.getElementsByName("Zutat")[0].checked = true;

Leave a Reply

Your email address will not be published. Required fields are marked *