Monday, May 16, 2005

IE and getElementById

See the following code. Guess which node id is "foo".
Firefox will tell you "INPUT", but IE "FORM".


<SCRIPT language="javascript">
function checkFoo() {
var fooNode = document.getElementById("foo");
alert(fooNode.tagName);
}
</SCRIPT>
<FORM name="foo">
Name : <INPUT type="text" id="foo">
<INPUT TYPE="button" onClick="checkFoo()" value="Get Foo Node">
</FORM>

No comments: