[thelist] dynamic javascript loop help

Hassan Schroeder hassan at webtuitive.com
Tue Jan 18 16:27:01 CST 2005


Joshua Olson wrote:

> Try this in IE and Moz:
> 
> <div id="test">
> This is the sentence<span>, in full</span>.
> </div>
> <script>
> alert(document.getElementById('test').firstChild.nodeValue);
> alert(document.getElementById('test').innerHTML);
> alert(document.getElementById('test').innerText);
> </script>
> 
> What do you get? 

In Firefox/Linux,

1: This is the sentence
2: This is the sentence<span>, in full</span>.
3: undefined

which is what I'd expect. (I'll let someone else try IE!)

> I suppose it would be helpful to know what sort of data we
> expect within the table cell.

Uh, yeah, which is why I cited the OP's example:

    <td id='row_0_col_0'>value here</td>

:: where there's clearly only a single child element. And since the
OP was also talking about doing something mathematical with the value
of the cell, it would be unlikely to have embedded markup...

If I were uncertain of the content of that cell, no, I wouldn't just
assume that firstChild == lastChild :-)

-- 
Hassan Schroeder ----------------------------- hassan at webtuitive.com
Webtuitive Design ===  (+1) 408-938-0567   === http://webtuitive.com

                           dream.  code.




More information about the thelist mailing list