ドキュメント

Selectors/parent

From jQuery JavaScript Library

Jump to: navigation, search

« Back to Selectors

:parent

Matches all elements that are parents - they have child elements, including text.
Examples:

Finds all tds with children, including text.

$("td:parent").fadeTo(1500, 0.3);

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
                    "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <script src="http://code.jquery.com/jquery-latest.js"></script>
  
  <script>
  $(document).ready(function(){
    $("td:parent").fadeTo(1500, 0.3);
  });
  </script>
  <style>
td { width:40px; background:green; }
  </style>
</head>
<body>
  <table border="1">
    <tr><td>Value 1</td><td></td></tr>
    <tr><td>Value 2</td><td></td></tr>
  </table>
</body>
</html>

NameType