I use this code:
>
Using getElementsByName to get a DOM Element where the name attribute is not part of the W3C spec (eg, in the question, name doesn't exist for DIV element), IE doesn't get those elements. FF does it.
Just to clarify: expando attribute or better known as custom attribute is what I am talking about attributes that are not part of the W3C spec.
Read: getElementsByName in IE7
Read: http://msdn.microsoft.com/en-us/library/ms536438(VS.85).aspx
So in conclusion:
Use getElementsByName when trying to get "Form Controls" (input, select, textarea) because they have name as an attribute according to the spec.
If the elements are not Form Controls, use getElementById instead.