Organizational Research By

Surprising Reserch Topic

is there a spec that the id of elements should be made global variable


is there a spec that the id of elements should be made global variable  using -'javascript,html,dom,global-variables,identifier'

If I have a <div id='a'> in Chrome then in javascript I can do a.stuff() (it's like as if a is a global variable).

However this does not work with FireFox - I will need to use document.getElementById('a').

What is the correct behaviour here? (according to W3 specs that is)

Also I'm interested in how will Chrome resolve the ambiguity if I have a div with id a yet have a global variable called a too in my script. Is the behavior going to be random and whacky?

And how would an element with id consisting of hyphens ("-"), colons (":"), and periods (".") be translated (ok i know they can be accessed with document.getElementById but how will the browser translate it into the global variable that was representing them)
    
asked Sep 9, 2015 by rajesh
0 votes
7 views



Related Hot Questions



Government Jobs Opening


...