I have an HTML code as given below.
I want to select all td which contains a(anchor) as an immediate child (Here First TD tag) using jQuery.
<table>
  <tr>
    <td><a href="abc.aspx">ABC</a></td>
    <td>Second Level<span> >> </span>
        <div>
          <table>
             <tr>
               <td><a href="efg.aspx">EFG</a></td>
             </tr>
          </table>
        </div>
    </td>
 </tr>
Many ways to do this
You can use the parent css selector or jQuery's parent() function.
Check out the sample and this jsFiddle Demonstration
$("td > a").parent()$("td > a:parent")This should do the trick:
$("td > a").parent();
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With