NS中getElementById中的name vs id [英] name vs id in getElementById in NS

查看:72
本文介绍了NS中getElementById中的name vs id的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我应该同时使用姓名和身份证吗

< div name =" abc" ID = QUOT; ABC">在NS中使用getElementById?

解决方案

2004年10月15日星期五10:45:44 -0400,nntp< nn ** @ rogers。 COM>写道:

我应该同时使用名称和ID
< div name =" abc" ID = QUOT; ABC">在NS中使用getElementById?




否,原因有两个:


1)getElementById只返回对元素的引用一个匹配的

id。虽然IE确实返回匹配的名称,但在这方面却被打破了[1]。

2)大多数元素没有名称属性,而那些只有

的元素继续使用它们以便与旧浏览器向后兼容

就像NN4一样。一个DIV当然没有,也从来没有一个名字

属性。


Mike


-

Michael Winter

替换.invalid与.uk通过电子邮件回复。


nntp说:


我应该同时使用名称和身份
< div name =" abc" ID = QUOT; ABC">在NS中使用getElementById?




在任何浏览器中使用getElementById

都不需要name属性。所有你需要的是一个id。


表格元素也应该有一个名字,如果他们的价值是

提交。


" NNTP" <ン** @ rogers.com>写道:

我应该同时使用名称和ID
< div name =" abc" ID = QUOT; ABC">在NS中使用getElementById?



什么NS(我假设是Netscape)?

不重要。 Netscape 4没有getElementById,Netscape 6+
符合标准,只能通过id找到元素。使用

getElementById。


div元素上从未有过name属性。 :)


/ L

-

Lasse Reichstein Nielsen - lr*@hotpop.com

DHTML死亡颜色:< URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>

'没有判断的信仰只会降低精神神圣。''


Should I use both name and id
<div name="abc" id="abc"> for using getElementById in NS?

解决方案

On Fri, 15 Oct 2004 10:45:44 -0400, nntp <nn**@rogers.com> wrote:

Should I use both name and id
<div name="abc" id="abc"> for using getElementById in NS?



No, for two reasons:

1) getElementById only returns references to elements that have a matching
id. Though IE does return matching names, it is broken in this respect[1].
2) The majority of elements do not have name attributes, and those that do
only continue to have them for backward compatibility with old browsers
like NN4. A DIV certainly does not have, nor has it ever had, a name
attribute.

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.


nntp said:


Should I use both name and id
<div name="abc" id="abc"> for using getElementById in NS?



There is no need for the name attribute for using getElementById
in any browser. All you need is an id.

Form elements should also have a name, if their value is being
submitted.


"nntp" <nn**@rogers.com> writes:

Should I use both name and id
<div name="abc" id="abc"> for using getElementById in NS?



What NS (which I assume means Netscape)?
Not that it matters. Netscape 4 has no getElementById and Netscape 6+
is standards compliant and only finds elements by their "id" using
getElementById.

And there was never a name attribute on div elements. :)

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
''Faith without judgement merely degrades the spirit divine.''


这篇关于NS中getElementById中的name vs id的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆