Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there guaranteed ordering on getElementsByName()?

Tags:

javascript

dom

Are the values returned by Javascript's getElementsByName(...) guaranteed to be in the same order that they appear in the DOM?

like image 877
elynnaie Avatar asked Oct 21 '25 09:10

elynnaie


1 Answers

with getElementsByName(name), the name is required, and thus the name order is irrelevent.

EDIT: I checked the specification and see nothing that would guarantee the order but I have never seen it OUT of order myself.

Spec: http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-71555259

like image 65
Mark Schultheiss Avatar answered Oct 24 '25 00:10

Mark Schultheiss