jquery 选择器 :first

:first

匹配结果集合中的第一个元素。返回匹配元素

<!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(){
    $("tr:first").css("font-style", "italic");
  });
  </script>
  <style>
  td { color:blue; font-weight:bold; }
  </style>
</head>
<body>
  <table>
    <tr><td>Row 1</td></tr>
    <tr><td>Row 2</td></tr>
    <tr><td>Row 3</td></tr>
  </table>
</body>
</html>

 

$("tr:first").css("font-style", "italic");

匹配tr元素集合中的第一个tr元素。以下为匹配元素

<tr><td>Row 1</td></tr>

你可能感兴趣的:(html,jquery,css)