Without using document.getElementById
Historic window object still retains features pertaining to the start of the Browsers era

A few weeks ago I was surprised at at the fact that something that seemed impossible was / is still possible.
I didn't realize that this was even possible in my 20+ years of web development. I even had a debate with my colleague about not using it that way but we weren't in sync.
Apparently - if you set in your HTML <input type="text" id="first_name" /> , you don't need to do document.getElementById('first_name').value - instead, you can directly call first_name.value !!!
https://codepen.io/anjanesh/pen/GRLJZrj
Apparently, this is still valid and is also in the HTML spec.
the value of the id content attribute for all HTML elements that have a non-empty id content attribute and are in a document tree with window's associated Document as their root.
About the author
- I am a web developer from Navi Mumbai. Mainly dealt with LAMP stack, now into Django and getting into Laravel and Cloud. Founder of nerul.in and gaali.in
Comments
Join the discussionNo comments yet. Be the first to comment.





