html中name和id的區別 [ZT]

來源:互聯網
上載者:User
name=id  
 
一個microsoft的 一個是netscape的   都是標記對象名稱  
---------------------------------------------------------------  
 
表單元素(form  input  textarea  select)與架構元素(iframe  frame)用  name  
這些元素都與表單(架構元素作用於form的target)提交有關,  在表單的接收頁面只  
接收有name的元素,  賦ID的元素通過表單是接收不到值的,  你自己可以驗證一下.  
 
當然上述元素也可以賦ID值,  賦ID值的時候引用這些元素的方法就要變一下了.  
賦  name:  document.formName.inputName        document.frames("frameName")  
賦  ID    :  document.all.inputID                      document.all.frameID  
 
只能賦ID不能賦name的元素:(除去與表單相關的元素都只能賦ID)  
body  li  a  table  tr  td  th  p  div  span  pre  dl  dt  dd  font  b  等等

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.