jQuery可见性选择器
更新:HHH   时间:2023-1-7


:hidden:表示查询所有隐蔽的标签
:visible:表示查询所有显示的标签
或:not(:hidden)

<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <script type="text/javascript" src="../js/jquery-1.6.js"></script>
  </head>
  <body>
    <table border="1" align="center">
      <tr >
        <td>Value 1</td>
      </tr>
      <tr>
        <td>Value 2</td>
      </tr>
      <tr>
        <td>Value 3</td>
      </tr>
    </table>
    <script type="text/javascript">

        //1)查找隐藏的tr元素的个数
        //alert($("table tr:hidden").size());
        //alert($("tr:hidden").size());

        //2)查找所有可见的tr元素的个数
        //alert($("table tr:visible").size());
        //alert($("table tr:not(:hidden)").size());

    </script>
  </body>
</html>
返回web开发教程...