I am trying to find the <div> parent of a <td> tag. In the following code, I do not understand why the alert shows 0 instead of 1??
<script type="text/javascript"> $(function(){ var x = $('#row_3'); var y = x.parent('div[id^=idSection_]'); alert( y.length ); }); </script> <div id="idSection_A" style="display: block;"> <table><tr><td id="row_1">eric 1</td></tr></table> </div> <div id="idSection_B" style="display: block;"> <table><tr><td id="row_2">eric 2</td></tr></table> </div> <div id="idSection_C" style="display: block;"> <table><tr><td id="row_3">eric 3</td></tr></table> </div>