html 中 id 和 name 的区别

[color=red]只有html中的name属性标识的域的值,才能被服务器端接收[/color]
原文链接
[url]
http://nadeeth.info/blog/node/20[/url]
Difference between HTML id and name attributes
Published
by
nadeeth
on Mon, 10/20/2008 - 11:16

* nadeeth's blog

[color=red][size=xx-large]Everybody knows that values that pass to the server using HTML forms are accessed by the ‘name' attribute.[/size][/color] What I am going to write here is not related to that server side form handling. Consider the DOM functions given below document.getElementById() and document.getElementsByName(). Using the first one (getElementById), you can access a one element uniquely. That means if you want to identify one single element uniquely you should use the id property. On the other hand, using second function (getElementsByName) you can get an array of elements that have the same name. No matter although there is one element in that particular name, this function returns an array. Some times, we have to use the same name for more than one element (Ex. Radio button groups, Etc...). After all, the name and id HTML properties are used for different purposes.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值