0

How can you travel between child of a particular element to the child of his sibling element it is necessary to go back to the father, namely to reach nephew But how?

The constraint is to start with one of the children(to see if he checked), I try to build a game that has to check whether all the input element pressed in a certain line.

lets say i have that structure and i want to find out if all input are clicked :

<table>
 <tr class="cell1">
    <td class="cell" >
     <input  id="c1" type="checkbox"   name="c1"  value="">
     <label class="cell" for="c1"></label>
     </td>
    <td class="cell">
     <input  id="c2" type="checkbox"   name="c1"  value="">
     <label class="cell" for="c2"></label>
    </td>
    <td class="cell">
     <input  id="c3" type="checkbox"   name="c1"  value="">
     <label class="cell" for="c3"></label>
    </td>
   </tr>
</table>
Ofer Eran
  • 1
  • 2

1 Answers1

0

It's not currently possible to get the parent of an element using a CSS selector, but you could get cousin elements using JavaScript if you were so inclined. Let's say the original element is el.

You could get to a cousin of el by doing this:

el.parentNode.parentNode.childNodes[x].getElementsByTagName(el.tagName)[0];

... where x is the td element number you want. It sounds like you will want to write a loop over all of them.

Maximillian Laumeister
  • 18,162
  • 7
  • 50
  • 70