How to change the background color of a row in a table?

How to change the background color of a row in a table?

Hi
I am trying to change the background color of a row within a table when the mouse is over that row.

I want to do that on all the tables in my site.

I found this code and tried to use it but it is not working


  1. $(document).ready(function() {

  2. //this code create the hover effect over the row's in every table
  3. $('table tr').hover(function() {
  4. $(this).addClass('tr_hover');
  5. }, function() {
  6. $(this).removeClass('tr_hover');
  7. });

  8. });


I have this css class 

  1. .tr_hover {
  2. background-color: #FFFF99; 
  3. }