document.all与document.getElementById [英] document.all vs. document.getElementById

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

问题描述

什么时候应该使用 document.all document.getElementById

推荐答案

document.all 是W3C标准的专有Microsoft扩展。

document.all is a proprietary Microsoft extension to the W3C standard.

getElementById()是标准的 - 使用它。

getElementById() is standard - use that.

但是,考虑使用像 jQuery 这样的js库会派上用场。例如, $(#id) getElementById()的jQuery等价物。另外,您可以使用不仅仅是CSS3 选择器。

However, consider if using a js library like jQuery would come in handy. For example, $("#id") is the jQuery equivalent for getElementById(). Plus, you can use more than just CSS3 selectors.

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

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