Specify the name of the label.
Format
<input type = text name = username />
Application scenarios
① Form form: name can be used as a variable name transferred to the server list list; as if the name passed to the server above is: username = 'text value'.
②Input Type = 'Radio' Single Tags: When setting the name of several single -selected labels to one of the same value, it will perform a single -selection operation.
<input type = radio name = 'sex'/> Male <input type = radio name = 'sex'/> female
③ Quickly obtain a set of the same name of Name: Get the label with the same name and operate together, such as changing attributes and registration events.
Function ChangtxtColor () {var txts = document.Getelementsbyname ('txtcolor'); // Get all name = txtcolor tags (var I = 0; i <txts.length; i ++) {/// Traveling through the label and put it The background color is changed to red txts [i] .style.backgroundcolor = 'red';}}characteristic
The value of the name attribute is not unique in the current Page page.
ID/256798.html "> IDSpecify the unique logo of the label.
Format
<input type = password id = userpwd />
Application scenarios
① Quickly obtain label objects according to the unique ID number provided. Such as: document.GetelementByid (ID)
② Value used to act as the Label tag attribute: Example: <Label for = 'Userid'> Username: </Label>, indicating that when you click this label tag, the ID is the focus of userid.
characteristic
The value of the ID attribute is unique on the current Page page.
classSpecify the name of the label.
Format
<input type = Button class = btnsubmit />
Application scenarios
①CSS operation, put some specific styles in a class class, you need to label this style, which can be added.
characteristic
You can put multiple classes in a class property, but you must be separated by space; such as: class = 'btnsubmit btnopen'