Name is used to submit data. It is provided to the form and can be repeated;
Id is used for document operations and cannot be repeated. For example, document. getElementById ();
1. ID is used in the client script! NAME is used to obtain information about a form field of the submitted form. In the form, if Name is not specified, it will not be sent to the server.
Ii. Names are used for the following elements: input, select, form, frame, and iframe, while IDs are used for the following elements: table, tr, td, div, p, span, h1, and li, form input textarea select and iframe frame use name. These elements are related to the form (the frame element acts on the target of the form) submission, only the element with name is received on the form receiving page, and the element with ID is not received through the form.
Of course, the above elements can also be assigned an ID value. The method for referencing these elements when assigning an ID value will be changed.
Assigned name: document. formName. inputName document. frames ("frameName ")
Assigned ID: document. all. inputID document. all. frameID
Only elements with ID and no name can be assigned: (only elements related to the form can be assigned ID)
Body li a table tr td th p div span pre dl dt dd font B and so on