<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 
<html> 
    <head> 
        <title>xx</title> 
        
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script language="javascript">
  $(function ($) { 
//行颜色效果
$('.all_cont tr').hover(
function () {
        $(this).children().css('background-color', '#ffff00');
},
function () {
        $(this).children().css('background-color', '#fff');
});
  });
</script>
    </head> 
    <body> 
<table width="200" border="1" class="all_cont">
  <tr>
    <td>a</td>
    <td>b</td>
    <td>c</td>
  </tr>
  <tr>
    <td>d</td>
    <td>e</td>
    <td>f</td>
  </tr>
  <tr>
    <td>g</td>
    <td>h</td>
    <td>i</td>
  </tr>
</table>    </body> 
</html>

解决方案 »

  1.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 
    <html> 
        <head> 
            <title>xx</title> 
            
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
    <script language="javascript">
      $(function ($) { 
    //行颜色效果
    $('.all_cont tr').hover(
    function () {
            $(this).children().css('background-color', '#ffff00');
    },
    function () {
            $(this).children().css('background-color', '#fff');
    });
      });
    </script>
        </head> 
        <body> 
    <table width="200" border="1" class="all_cont">
      <tr>
        <th colspan="3">abc</th>
      </tr>
      <tr>
        <td>a</td>
        <td>b</td>
        <td>c</td>
      </tr>
      <tr>
        <td>d</td>
        <td>e</td>
        <td>f</td>
      </tr>
      <tr>
        <td>g</td>
        <td>h</td>
        <td>i</td>
      </tr>
    </table>    </body> 
    </html>看这个,如果是th的话,则行背景颜色和字体颜色都不改变。
      

  2.   

    $(function ($) { 
        //行颜色效果
        $('.all_cont tr').hover(
        function () {
            $(this).children().css('background-color', '#ffff00');
            $(this).find("td").css('color', 'red');
                
        },
        function () {
            $(this).children().css('background-color', '#fff');
             $(this).find("td").css('color', 'black');          
        });
      });
      

  3.   

    试试这个
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 
    <html> 
        <head> 
            <title>xx</title> 
            
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
    <script language="javascript">
      $(function ($) { 
    //行颜色效果
    $('.all_cont tr').hover(
    function () {
            $(this).children().css('background-color', '#ffff00');
    $(this).children().css('color', 'red');
    },
    function () {
            $(this).children().css('background-color', '#fff');
    $(this).children().css('color', '#000');
    });
      });
    </script>
        </head> 
        <body> 
    <table width="200" border="1" class="all_cont">
      <tr>
        <th colspan="3">abc</th>
      </tr>
      <tr>
        <td>a</td>
        <td>b</td>
        <td>c</td>
      </tr>
      <tr>
        <td>d</td>
        <td>e</td>
        <td>f</td>
      </tr>
      <tr>
        <td>g</td>
        <td>h</td>
        <td>i</td>
      </tr>
    </table>    </body> 
    </html>
      

  4.   

    th 外
    $('.all_cont tr:has(td)').hover(
        function () {
            $(this).children().css('background-color', '#ffff00');
            $(this).find("td").css('color', 'red');
                
        },
        function () {
            $(this).children().css('background-color', '#fff');
             $(this).find("td").css('color', 'black');          
        });
      

  5.   

    楼主试试。
             $(function($) {
                    //行颜色效果
                    $('td').hover(function() {
                        $(this).parent().css({'background-color':'#ffff00','color':'red'});
                    }, function() {
                        $(this).parent().css({'background-color':'#fff','color':'black'});
                    });
                });