We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS

document.getElementsByName Redirect 1

« document


Returns a list of elements with a given name in the (X)HTML document.


elements = document.getElementsByName(name) 
  • elements is an HTMLCollection of elements.
  • name is the value of the name attribute of the element.


<!DOCTYPE html>
<html lang="en">

<form name="up"><input type="text"></form>
<form name="down"><input type="text"></form>

var up_forms = document.getElementsByName("up");
w(up_forms[0].tagName); // returns "FORM"


The name attribute is only applicable to (X)HTML documents. The method returns all elements with a name attribute, such as <meta> or <object> or even if name is placed on elements which do not support a name attribute at all.

document.getElementsByName() returns an HTMLCollection of all the elements with a given value for the name attribute.


Document Tags and Contributors

Last updated by: Sheppy,