首页 > 代码库 > 可见性选器

可见性选器

$("table tr:hidden")
$("table tr:visible")

 

 

 1 <html> 2   <head> 3     <meta http-equiv="content-type" content="text/html; charset=UTF-8"> 4     <script type="text/javascript" src="../js/jquery-1.8.2.js"></script> 5   </head> 6   <body> 7     <table border="1" align="center"> 8       <tr style="display:none"> 9           <td>Value 1</td>10       </tr>11       <tr>12           <td>Value 2</td>13       </tr>14       <tr>15           <td>Value 3</td>16       </tr>17     </table>18     <script type="text/javascript">19     /*1)查找隐藏的tr元素的个数20         */21         alert( $("table tr:hidden").size() );22         23       /*2)查找所有可见的tr元素的个数24           alert( $("table tr:not(:hidden)").size() );25           alert( $("table tr:visible").size() );26           alert( $("tr:visible").size() );27           */28 29     </script>30   </body>31 </html>