coderex coderex - 2 months ago 5
Javascript Question

document.all vs. document.getElementById

When should you use

document.all
vs.
document.getElementById
?

Answer

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

getElementById() is standard - use that.

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.

Comments