Getting the correct node
        Posted  
        
            by YsoL8
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by YsoL8
        
        
        
        Published on 2010-05-03T18:50:12Z
        Indexed on 
            2010/05/03
            19:08 UTC
        
        
        Read the original article
        Hit count: 285
        
JavaScript
|dom
Hello
I have this structure in my dom:
<label>London<input type="checkbox" name="London"></label><br>
<div class="innerpost">
<label>N1 2AB<input type="checkbox" name="N1 2AB"></label><br>
<label>E1 1AB<input type="checkbox" name="E1 1AB"></label><br>
</div>
I need a way to select the div from the first checkbox. Something like
 parentNode.parentNode.getElementsByTagName("div");
But I'm not getting it right - that particular line selects all the divs one parent above the one I need.
© Stack Overflow or respective owner