javascript not working properly in Mozilla v1.0 but same code is working fine in IE v6.0
Created May 8, 2012
Axel Richter Hi,
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:
You have to test which node type you've gotten with .firstChild or you have to get the desired element directly with getElementById().
Greetings
Axel
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"> <p>test</p> </div> <script type="text/javascript"> <!-- var node = document.getElementById("mydiv"); alert(node.firstChild.nodeType); //--> </script>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().
Greetings
Axel