将鼠标悬停在<tr>上时更改<a>的链接颜色

nid*_*dis 0 html css jquery

当我将鼠标悬停在上面时<tr>,<a>元素的颜色应该变为白色.

我尝试使用类似的jQuery:

<script>
    $('tr').hover(function(){
        $('a').css('color','white');
    });
</script>
Run Code Online (Sandbox Code Playgroud)

但这会改变所有人的文字颜色<tr>.任何的想法?

html和css代码:

Qua*_*cal 9

将此行添加到CSS文件中并忘记jQuery:

tr:hover a { color: white; }
Run Code Online (Sandbox Code Playgroud)

如果你迫切希望你的jQuery代码能够工作,那么你需要只针对悬停行中的锚点:

$('tr').hover(function(){
   $('a', this).css('color','white');
 });
Run Code Online (Sandbox Code Playgroud)