Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用jquery向悬停时的表行添加背景色和边框_Jquery_Css - Fatal编程技术网

使用jquery向悬停时的表行添加背景色和边框

使用jquery向悬停时的表行添加背景色和边框,jquery,css,Jquery,Css,有人知道当鼠标悬停在一行上时,用不同的背景色向一行添加边框的方法吗 我已经能够使用以下命令更改行的背景颜色: $(document).ready(function() { $(function() { $('.actionRow').hover(function() { $(this).css('background-color', '#FFFF99'); }, function() { $(t

有人知道当鼠标悬停在一行上时,用不同的背景色向一行添加边框的方法吗

我已经能够使用以下命令更改行的背景颜色:

$(document).ready(function() {
   $(function() {
        $('.actionRow').hover(function() {
            $(this).css('background-color', '#FFFF99');
        },
        function() {
            $(this).css('background-color', '#FFFFFF');
        });
    });
});
但我无法添加边框颜色。我意识到边框不能直接应用于表行标记,但我希望有人知道一些jQuery巫术,可以找到所选行中的表单元格,并对这些单元格应用一些样式来创建边框


谢谢

也许这是一个很好的起点:


您最好的选择是在行中添加类和删除类。 然后在样式表中:

.actionRow-hovered td { border-color: whatever; }
因此,您将实际操作每个td边框颜色。 这是一种痛苦,但当你掌握了窍门时,效果就足够好了

   $(function() {
        $('tr').hover(function() {
            $(this).css('background-color', '#FFFF99');
            $(this).contents('td').css({'border': '1px solid red', 'border-left': 'none', 'border-right': 'none'});
            $(this).contents('td:first').css('border-left', '1px solid red');
            $(this).contents('td:last').css('border-right', '1px solid red');
        },
        function() {
            $(this).css('background-color', '#FFFFFF');
            $(this).contents('td').css('border', 'none');
        });
    });

其中,
tblMenuTabls
是表类名称,
tblOverRow
是带有悬停定义的CSS类

这是整个表的边框,而不是单独的行。在IE7中有点松鼠。数字。
$('table.tblMenuTabls tr').hover(function(){
        $(this).toggleClass('tblOverRow');
        },function(){
            $(this).toggleClass('tblOverRow')}
    ).css({cursor: 'hand'});