E
Ed Weatherup
Apologies if this is answered elsewhere (although I have googled the
group and read the FAQ) but ...
.... why should I use document.getElementById instead of referring to the
HTML element directly?
Given the HTML fragment ...
<div id="redBook"> ... content ... </div>
Why should I use ...
<script>
document.getElementById("redBook").style.visibility = "hidden";
document.getElementById("redBook").style.cursor = "pointer";
</script>
.... instead of ...
<script>
redBook.style.visibility = "hidden";
redBook.style.cursor = "pointer";
</script>
The reason I ask is that a colleague points to the warnings[1] in the
Firefox error console but other than saying "It's a W3C compliance issue
...." he is unable to explain further.
[1] Element referenced by ID/NAME in the global scope. Use W3c standard
document.getElementById() instead.
Many thanks in advance.
group and read the FAQ) but ...
.... why should I use document.getElementById instead of referring to the
HTML element directly?
Given the HTML fragment ...
<div id="redBook"> ... content ... </div>
Why should I use ...
<script>
document.getElementById("redBook").style.visibility = "hidden";
document.getElementById("redBook").style.cursor = "pointer";
</script>
.... instead of ...
<script>
redBook.style.visibility = "hidden";
redBook.style.cursor = "pointer";
</script>
The reason I ask is that a colleague points to the warnings[1] in the
Firefox error console but other than saying "It's a W3C compliance issue
...." he is unable to explain further.
[1] Element referenced by ID/NAME in the global scope. Use W3c standard
document.getElementById() instead.
Many thanks in advance.