jQuery Table How to - Select second table row








Question

We would like to know how to select second table row.

Answer


<!--  ww  w  .  j a v a  2s. co m-->
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.10.1.js'></script>
<script type='text/javascript'>
$(window).load(function(){
    $("#table-id tr:eq(1) td").css('padding','25px').css('background','red');
});
</script>
</head>
<body>
  <table id="table-id" style="text-align: center;">
    <tr>
      <th>a</th>
    </tr>
    <tr>
      <td>b</td>
    </tr>
    <tr>
      <td>c</td>
    </tr>
  </table>
</body>
</html>

The code above is rendered as follows: