Today <a href=#13></a> has doubts, plus # means one, followed by 13, and jump to the position of 13 on the surface, and 13 is the Name value. Why not
Is it an ID value? ? ? So I checked the ID and Name,
The most classical answer: ID is like a person's ID number, and Name is like his name. ID is obviously unique, and Name is repeatable.
Obviously, the answer to this ID and Name is too general. Of course, that explanation is completely correct for the ID. It is the Identity of the HTML element on the Client. Name is actually much more complicated because Name has many uses, so it cannot be replaced by ID, thus canceling it. Specific uses are:
Purpose 1: As a server-side label for HTML elements that can interact with the server, such as input, select, textarea, and button. We can get the value submitted by the element through Request.Params on the server side according to its Name.
Purpose 2: HTML elements Input type='radio' are grouped. We know that the radio button control is in the same grouping class. The check operation is mutex. Only one radio can be selected at the same time. This grouping is implemented based on the same Name attribute.
Purpose 3: Create an anchor in the page. We know that <a href=URL>link</a> is to obtain a page hyperlink. If we do not use the href attribute, we use Name instead, such as: <a name=PageBottom></a>, we obtain a page anchor.
Purpose 4: Identity as an object, such as Applet, Object, Embed and other elements. For example, in an Applet object instance, we will use its Name to reference the object.
Purpose 5: When associating between IMG elements and MAP elements, if you want to define the hotspot area of the IMG, you need to use its attribute usemap to make usemap=#name(the associated MAP
The name of the element).
Purpose 6: Attributes of certain specific elements, such as attribute, meta and param. For example, define the parameter <PARAM NAME = appletParameter VALUE = value> for Object or <META NAME = Author CONTENT = Dave Raggett> in Meta.
Obviously, these uses cannot be replaced by simply using IDs, so the ID of HTML elements and Name are not the difference between ID numbers and names. They are actually different.
Used stuff.
We can analyze the subtle differences through a piece of code:
Copy the code