If I only have a reference to document.getElementById(‘btn_test’), how can I get a reference to that first checkbox input element using only Javascript. Maybe a parent.parent? What is a safe way?
<td>
<input type="checkbox" name="text_rnd_input"/>
<label>
<button id="btn_test" type="button"></button>
</label>
</td>
Take care, if you use
*Sibingproperties, because they also select text nodes (for example, invisible ones with only whitespace) and are therefore usually not reliable with arbitrary HTML (think of compressing your HTML by removing whitespace).And to stress the inevitable: With jQuery: