jQuery Selector How to - Select all elements that are parents








Question

We would like to know how to select all elements that are parents.

Answer


<!--   w  ww.j a v a2s.  c  om-->
<html>
  <head>
    <script type="text/javascript" src='http://code.jquery.com/jquery-1.5.2.js'></script>
    <script type="text/javascript">
        $(document).ready(function(){
            $("td:parent").fadeTo(1500, 0.3);
        });
    </script>
  </head>
  <body>
    <body>
       <table border="1">
          <tr><td>Value 1</td><td></td></tr>
          <tr><td>Value 2</td><td></td></tr>
       </table>

    </body>
</html>

The code above is rendered as follows: