I volontari di MDN non hanno ancora tradotto questo articolo in Italiano. Unisciti a noi e traducilo tu stesso.
Puoi anche consultare l’articolo in English (US).

name gets or sets the name property of an element in the DOM. It only applies to the following elements: <a>, <applet>, <button>, <form>, <frame>, <iframe>, <img>, <input>, <map>, <meta>, <object>, <param>, <select>, and <textarea>.

Note: The name property doesn't exist for other elements; unlike tagName and nodeName, it is not a property of the Node, Element or HTMLElement interfaces.

name can be used in the document.getElementsByName() method, a form and with the form elements collection. When used with a form or elements collection, it may return a single element or a collection.


HTMLElement.name = string;
var elName = HTMLElement.name;

var fControl = HTMLFormElement.elementName;
var controlCollection = HTMLFormElement.elements.elementName;


<form action="" name="formA">
  <input type="text" value="foo">

<script type="text/javascript">

  // Get a reference to the first element in the form
  var formElement = document.forms['formA'].elements[0];

  // Give it a name
  formElement.name = 'inputA';

  // Show the value of the input


In Internet Explorer (IE), the name property of DOM objects created using document.createElement() can't be set or modified.


W3C DOM 2 HTML Specification:

Tag del documento e collaboratori

Hanno collaborato alla realizzazione di questa pagina: Sheppy, fscholz, s-n-ushakov, teoli, rogerhc, kscarfone, vishu_gawli, DomenicDenicola, dextra, Ms2ger, Mgjbot, Ptak82, Nickolay, RobG
Ultima modifica di: Sheppy,