Select cell by index

Description

The following code shows how to select third table cells with Element at index selector $("td:eq(2)").

Example


<html>
<head>
<script
  src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
  $(document).ready(function() {<!--  w  w  w . ja  v a  2 s . com-->
    $("td:eq(2)").css("color", "red");
  });
</script>
</head>
<body>
  <table border="1">
    <tr>
      <td>TD #0</td>
      <td>TD #1</td>
      <td>TD #2</td>
    </tr>
    <tr>
      <td>TD #3</td>
      <td>TD #4</td>
      <td>TD #5</td>
    </tr>
    <tr>
      <td>TD #6</td>
      <td>TD #7</td>
      <td>TD #8</td>
    </tr>
  </table>
</body>
</html>

Click to view the demo





















Home »
  jQuery »
    jQuery Example »




Animation
DOM
Event
Form
List
Select
Style
Table
Utilities