gpt4 book ai didi

查询。突出显示表格单元格

转载 作者:太空宇宙 更新时间:2023-11-04 04:37:18 25 4
gpt4 key购买 nike

在 HTML 表格上,当鼠标悬停在单元格 (TD) 上时,我想:

  1. 将 css 类“Highlight_TR_TH”添加到单元格的行。

  2. 将 css 类“Highlight_TD”添加到同一行的所有单元格

  3. 将 css 类“Highlight_This_Cell”添加到单元格本身。

基本上,我希望更改此元素的背景颜色。

我该怎么做?

最佳答案

$('td').hover(function(){
$(this).addClass('highlight_this_cell');
$(this).parent().addClass('highlight_tr');
$(this).parent().find('td').addClass('highlight_td');
},function(){
$(this).removeClass('highlight_this_cell');
$(this).parent().removeClass('highlight_tr');
$(this).parent().find('td').removeClass('highlight_td');
}
);

.hover() 有两个函数,第一个在 mouseover 时执行,第二个在 mouseleave 时执行。

关于查询。突出显示表格单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16103077/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com