Why some HTML elements are available as javascript global variables and other elements are not?
Why an input element is visible as global variable only if it is outside of a form?
With this simple page:
<html>
<body>
<form id="form1">
<input id='input1' />
<div id='div1'></div>
</form>
</body>
</html>
I have both div1
and input1
as global variables in Chrome, but in IE10 I input1
is undefined: http://jsfiddle.net/M5ExX/
If I remove the form and leave the div and the input, then both are defined, both in Chrome and in IE: http://jsfiddle.net/M5ExX/1