In-depth learning HTML: Humble ID and Name attributes of distinction

Related Tags:

  It can be said that almost every development of the Web done all asked, in the end elements of the id and Name What is the difference between Afghanistan?    Why ID will have a Name?! And Similarly, we can also be the most classical answer to the question: ID is like a person's identity card number, and Name is like his name, is the only ID, and can Name repetitive. 

  Last week I also encountered the problem of ID and Name, type in a page input type = "hidden", which wrote an ID = 'SliceInfo', assigned submit, in the Background with Request.Params [ "SliceInfo "] but also how not to value.    Later came because of the marking by Name, so the input of the Riga Name = 'SliceInfo' on the all ok. 

  In the first paragraph of the ID and Name answers that were too general, of course explain that the ID is completely right, and it is the Client-HTML elements Identity.    Name and actually more complicated, because there are different types of Name purposes, so it can not be fully replaced by the ID, which will be its Quxiaodiao.    Specific uses: 

  Use 1: As with interactive data server html Element marking the end of the server, such as input, select, textarea, and the button, etc..    We can Name Server under its Request.Params made by the value of the element. 
  Uses 2: HTML element Input type = 'radio' division, we know that the radio button controls in the same sub-category, check operation is mutex, selected the same time only a radio, this group is under the same Name attribute to them. 
  Uses 3: A page for the anchor, we know that <a href = "URL"> link </ a> is access to a page hyperlink, if not href attribute, instead Name, such as: <a name = "PageBottom"> </ a>, we received a page anchor. 
  Uses 4: As Object Identity, such as Applet, Object, Embed and other elements.    For example, in Applet instance, we will use to invoke the Name of the object. 
  Uses 5: IMG element in the MAP and the linkages between elements, if it is used to define a hot IMG region, need to use their property usemap, usemap = "# name" (MAP was linked to elements of Name). 
  Uses 6: certain elements of the attributes, such as attribute, meta and param.    Object definition of parameters such as <PARAM NAME = "appletParameter" VALUE = "value"> or in Meta <META NAME = "Author" CONTENT = "Dave Raggett">. 

  Clearly these purposes is not simple to use ID to replace the swap, so HTML elements of the ID and Name it is not the identity card number and other names such differences, which are more of this is the role of different things. 

  Name of course, the HTML element attributes in the pages can also play a role so that the ID, because the DHTML object tree, we can use to obtain a document.getElementsByName page contains all the elements specified Name Object array.    Name attribute there is a problem, when we can create dynamic Name attribute contains the element, not simply the use of assignment element.name = "..." add to its Name, but must be in the creation of Element, the use of document.createElement ( '<element name = "myName"> </ element>') to add elements Name attribute.    What does this mean ah?    Look at the following example to understand. 

  <script Language="JavaScript"> 
  Var input = document.createElement ( 'INPUT'); 
  Input.id = 'myId'; 
  Input.name = 'myName'; 
  Alert (input.outerHTML); 
  </ Script> 

  The results show that the information box: <INPUT id = myId>. 

  <script Language="JavaScript"> 
  Var input = document.createElement ( '<INPUT name="myName">'); 
  Input.id = 'myId'; 
  Alert (input.outerHTML); 
  </ Script> 

  The results show that the information box: <INPUT id = myName myId name =>. 

  Initialization Name attributes of the design is not IE flaw, because MSDN, said the need to do so, but this design principle?    I do not have too much to understand. 

  Here again the way, if pages are n (n> 1)-HTML elements of the ID are the same how do?    In the DHTML object in how they use?    If we use ASPX pages, the situation is not so high, because aspnet process in dealing with the aspx page simply does not allow any non-ID only, which is abnormal pages will be thrown out can not be normal render.    If not dynamic pages, we insist on ID to repeat that IE how engaging?    This time, we can still continue to use document.getElementById acquisition target, but we can only obtain ID duplicate those in the HTML Render object when the object first.    And then repeat the ID will be invoked automatically become an array, ID Render repetitive elements of the order exists in the array. 

Related articles:

CSS sel
  CSS selector is our choice at CSS page layout of the foundation.    CSS selector which in the end, how to use reasonable?    Selectors can be divided into three categories, in addition to the first category HTML selector, the other two we can own name, in naming, to includ...
Venture Vanguard: MM unarmed create a fashion empire information
  A year's time, up to 10 hours a day finishing boring, update, a day less than 1000's IP, there are close to 50,000 of pv, Category 1600, 881 world-class brands, models 130000, more than 40 10,000 photographs, the growth of the figures prove that a head of the MM hard and sweat. ...
Use the advantages of xhtml + css
  1. Follow web standards.    2. Structure and performance of phase separation, and the original html structure and performance of mixed up together.    Many traditional web developer is still using the form layout, structure and performance of hybrid approach.   ...
AJAX basis - Chapter 2 (4)
  HTML <form> Tags:    Form elements can be created for user input forms.    Forms can contain text field, check box, radio button, and so on.    Form is used to designate the URL to a user data transfer.    Essential attributes: in the form defi...
Dreamweaver added to the vertical line
  Website frequently used when making an pixels high or wide fine line to tinkering with the layout of web pages can be more clear, more beautiful whole.    As has been customary to use Dreamweaver edit page, in reading "clever in Fontpage website to join in a vertical line"...