jQuery Selector How to - nth-child(odd); Skip every other cell on hover with highlight








Question

We would like to know how to nth-child(odd); Skip every other cell on hover with highlight.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
td:nth-child(odd) {<!--  w  w  w. jav  a  2s. com-->
  background: red;
}

td:nth-child(odd):hover {
  background: yellow;
}
</style>
</head>
<body>
  <table>
    <tr>
      <td>Word</td>
      <td>000</td>
      <td>Word</td>
      <td>123</td>
    </tr>
  </table>
</body>
</html>

The code above is rendered as follows: