javascript - Odd DOM Problem with Firefox -


Using a javascript, I have a strange problem while navigating through the rows and cells of a table in a time loop. Is facing. I'm using Firefox 3.5.7 on Win7 with Firebug enabled.

I have this markup:

  & lt; Table & gt; & Lt; Tbody & gt; & Lt; Tr id = 'firstrow' & gt; & Lt; Td> A & lt; / Td> & Lt; Td> B & lt; / Td> & Lt; TD & gt; C & lt; / Td> & Lt; / Tr & gt; & Lt; TR & gt; & Lt; TD & gt; & Lt; / TD & gt; & Lt; TD & gt; B & lt; / TD & gt; & Lt; TD & gt; C & lt; / TD & gt; & Lt; / TR & gt; & Lt; TR & gt; & Lt; TD & gt; & Lt; / TD & gt; & Lt; TD & gt; B & lt; / TD & gt; & Lt; TD & gt; C & lt; / TD & gt; & Lt; / TR & gt; & Lt; / Tbody & gt; & Lt; / Table & gt;  

and this javascript:

  var line = document.getElementById ('first'); Console.log (line); // call cry while 1 (line) {console.log (line); // cry call 2 line = row.Next sibling; }  

The problem I have is commenting on "Row call 1" on the line, firebug is output

   

As expected, while in the loop, Firebug is giving me

   

This is giving me different outputs for the exact same line, even when the loop starts, and when anything touches the line, the later lines For, there is no attribute in it id = 'first line'

The big problem giving me this is that if I am in the loop of time, and I use the Row.cells [0], the special cell of the current row, Firebug will give me an error that the row. Cells is undefined.

I want to know that someone can put some light on this situation.

Firefox picked white position as an additional between your tr elements Node has been Simply add a test that the node is actually a tr before doing something with it:

  var row = document.getElementById ('firstRow'); Console.log (line); // line call 1 while (line) {if (row.nodeName == "TR") {console.log (line); // cry call2} line = row Newcast Sibling; }  

Note that the text node has node name of #text and it will always return nodename The name of the element in all documents, whether it is in your document.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -