Chinaunix首页 | 论坛 | 博客
  • 博客访问: 530748
  • 博文数量: 104
  • 博客积分: 2089
  • 博客等级: 大尉
  • 技术积分: 1691
  • 用 户 组: 普通用户
  • 注册时间: 2010-06-29 08:48
文章分类

全部博文(104)

文章存档

2015年(1)

2013年(13)

2012年(31)

2011年(59)

分类: Web开发

2013-10-09 14:43:44

在HTML中元素的ID和Name的区别和联系。
今天写了个测试,在php脚本里怎么也获取不到$_POST['userName']的值,经检查在html页面只写了input的Id,没有写Name。

现总结网上的帖子:

Name Attribute
Valid only on a, form, iframe, img, map, input, select, textarea
Name does not have to be unique
Can not be referenced in URL
Is referenced in JS with getElementsByName()
Shares same name space as id attribute
Must begin with a letter
Is case sensitive
Used on form elements to submit information
Id Attribute
Valid on any element
Each Id should be unique
Can be used as anchor reference in URL
Is referenced in CSS or URL with # sign
Is referenced in JS with getElementById()
Shares same name space as name attribute
Must begin with a letter
Is case sensitive

参考: 1 
2 http://www.cnblogs.com/birdshome/archive/2005/01/31/99562.html




阅读(1253) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~