Home  >  Article  >  Web Front-end  >  js在Firefox与IE中对DOM对像的引用的比较_javascript技巧

js在Firefox与IE中对DOM对像的引用的比较_javascript技巧

WBOY
WBOYOriginal
2016-05-16 18:51:59944browse

1.直接用ID属性进行引用


[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]

代码如上,测试表时在IE下有效,Firefox中无效。
2.直接用NAME属性进行引用

[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]

代码如上,在FF和IE下均无效,记得以前在网上看过有人用NAME去引用,不知是自己记错了还是什么。
3.使用getElementById(),getElementsByName(),getElementsByTagName()进行引用

[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]

代码如上,在FF和IE下均用效。
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn