使用jquery在悬停上添加背景颜色和边框到表格行

前端之家收集整理的这篇文章主要介绍了使用jquery在悬停上添加背景颜色和边框到表格行前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
有没有人知道如何在鼠标悬停在行上时将边框添加到具有不同背景颜色的表格行的边框?

我已经能够改变行的背景颜色:

@H_301_4@$(document).ready(function() { $(function() { $('.actionRow').hover(function() { $(this).css('background-color','#FFFF99'); },function() { $(this).css('background-color','#FFFFFF'); }); }); });

但是我无法添加边框颜色.我意识到边框不能直接应用到表行标签,但我希望有人知道一些jQuery巫术魔法,可以在所选行中找到表格单元格,并为创建边框应用一些样式.

谢谢!

解决方法

@H_301_4@$(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'); },'#FFFFFF'); $(this).contents('td').css('border','none'); }); });

猜你在找的jQuery相关文章