childnodes problem

Discussion in 'JavaScript' started by katyak, Mar 4, 2007.

  1. #1
    I'm really new to web programming. I've got the following code:
    <div id = "divrow1" name="divrow1">
    <tr id="row1.1" style="display=none;" name="row1.1">
    <td>&nbsp;<img id= 'imgrow1.1' src='images/plus.gif' <onclick='changeVis("row1.1", 3);' > Welcome</td>
    <td>1</td>
    <td>2</td>
    <td>3</td>
    </tr>
    </div>

    div = document.getElementById("divrow1");
    Why do I get zero for div.childNodes.length? :(
    Thank you
     
    katyak, Mar 4, 2007 IP
  2. Aragorn

    Aragorn Peon

    Messages:
    1,491
    Likes Received:
    72
    Best Answers:
    1
    Trophy Points:
    0
    #2
    You can't have a tr element inside a div element. <tr> needs to be enclosed within <table> tags
     
    Aragorn, Mar 4, 2007 IP
  3. katyak

    katyak Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    it's all within a <table> tag:
    <table id = "table1" border="1">
    <tbody>
    <tr>
    <th></th>
    <th>First</th>
    <th>Second</th>
    <th>Third</th>
    </tr>
    <tr id="row1" name="row1" >
    <td><img id= 'imgrow1' src='images/plus.gif' onclick='changeVis("row1", 2);' > Israel</td>
    <td>1</td>
    <td>2</td>
    <td>3</td>
    </tr>
    <div id = "divrow1" name="divrow1">
    <tr id="row1.1" style="display=none;" name="row1.1">
    <td>&nbsp;<img id= 'imgrow1.1' src='images/plus.gif' onclick='changeVis("row1.1", 3);' > Welcome Screen</td>
    <td>1</td>
    <td>2</td>
    <td>3</td>
    </tr>
    </div>

    and so on... How can I get the childNodes of the div "divrow1"?
     
    katyak, Mar 4, 2007 IP
  4. Aragorn

    Aragorn Peon

    Messages:
    1,491
    Likes Received:
    72
    Best Answers:
    1
    Trophy Points:
    0
    #4
    Thats wrong. Inside a table, a div element can exist only inside a <td> or <th> element.
     
    Aragorn, Mar 4, 2007 IP