You might try just var y = x.parent('div');
Would there ever be another div that could be a parent of one of these TD tags? -----Original Message----- From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On Behalf Of elubin Sent: Tuesday, May 19, 2009 12:47 PM To: jQuery (English) Subject: [jQuery] help using parent() 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>