javascript not working properly in Mozilla v1.0 but same code is working fine in IE v6.0

Axel Richter


the property [Node].firstCild contains the first cild node of the given node. This node may be a text node or a element node. For example:

<div id="mydiv">
<script type="text/javascript">
var node = document.getElementById("mydiv");
MSIE alerts "1", that is the element node P. Mozilla alerts "3", that ist the text node whitespace between begin of DIV and begin of P. For nodes look at http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1950641247.

You have to test which node type you've gotten with .firstChild or you have to get the desired element directly with getElementById().