nextSibling issue, should be simple
        Posted  
        
            by SoLoGHoST
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by SoLoGHoST
        
        
        
        Published on 2010-05-24T22:00:02Z
        Indexed on 
            2010/05/24
            22:11 UTC
        
        
        Read the original article
        Hit count: 198
        
JavaScript
|siblings
Ok, I'm trying to come to grips with this nextSibling function in JS. Here's my issue within the following code...
var fromRow = document.getElementById("row_1");
while(fromRow.nodeType == 1 && fromRow.nextSibling != null)
{
    var fRowId = fromRow.id;
    if (!fRowId) continue;
    // THIS ONLY gets done once and alerts "row_1" ONLY :(
    alert(fRowId);
    fromRow = fromRow.nextSibling;
}
Ok can someone please tell me what is wrong with this code?  There are siblings next to this document.getElementById("row_1"); element for sure as I can see them, and they all have id attributes, so why is it not getting the id attributes of the siblings??  I don't get it.
row_1 is a TR element, and I need to get the TR elements next to it within this table, but for some reason, it only gets the 1 element that I can already get using document.getElementById, arggg.
Thanks guys :)
© Stack Overflow or respective owner