I've noticed in several browsers, dom elements can be accessed simply by their id like this:
HTML
<div id="chocolat"></div>
JS
alert(chocolat.id); //alerts "chocolat
chocolat; //points to the node
window.chocolat; //idem
chocolat === document.getElementById('chocolat'); // true
( test here: http://jsfiddle.net/GUUPT/ ) This will work on some versions of IE, on Chrome, but it won't on Firefox(5).
I'm curious where does this come from ? is it in the standards?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With