Image with id no longer appears on document unless it has name as well

Published: | Categories: DOM


Previously, images with an id attribute were always available on document, so that <img id="foo"> was accessible via This behaviour has been changed to comply with the spec, and now images with an id attribute as well as a non-empty name attribute will only create named properties on document. For a better cross-browser compatibility, it is recommended to always use the document.getElementById method instead.