When creating web pages, I always used the function
var someVariable = document.getElementById('myID');
to get a link to the item object. I was recently suggested that this is not necessary because such a variable already exists. This name is id. I tested it and it works.
<div id="myID">some text</div> <a href="someplace" onclick="alert(myID.innerHTML)">click here</a>
This code works and it warns "some text" as expected. There is a warning in the firefox console:
referring to ID / NAME in global area. Use WC3 standard document.getElementById () instead.
I mostly use jQuery, but I need to prove that my boss is at work, or I have to buy him a box of chocolate :-).
Any ideas why the top code should not work or why it is a very wrong idea to use it (warning in firefox is not enough) ???
thank you for your responses
javascript getelementbyid
Voooza
source share