表单name与id的区别和相似之处

Published by Sean_Loo at 2008-3-30 with 0 review(s), ? hits. [Articles]

表单的name与id其实是同一个意思,都是为了标记对象名称。

它们所不同的是:name是Netscape的、id是Microsoft的。

表单元素(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  等等

http://www.xvdesign.com/articles/difnameid.html
Previous: alexheuchert
Next: revota



News and coming

Directories

抓虾 Rojo
google reader bloglines
my yahoo 哪吒

Resources

Status

  • []Writings
  • []Reviews
  • lx-super[A]163.comSean_Loo
鄂ICP备07004579号 Powered by Sean_Loo. All right reserved. W3CSitemap