【发布时间】:2014-12-29 21:53:33
【问题描述】:
如果您查看附图,在第二个表格中,当光标移动到包含4 的单元格时,第一个表格中的所有对应文本都会突出显示。我设法使用hover 函数实现了这一点:
/////////////////////////////////////////////////////////////
function HightLightTable1() {
// 0
$(".t1_h_x0").hover(
function () {
$(this).css("background-color", "yellow");
$(".t1_t_x0").css("background-color", "yellow");
}, function () {
$(this).css("background-color", "white");
$(".t1_t_x0").css("background-color", "white");
}
);
// 1
$(".t1_h_x1").hover(
function () {
$(this).css("background-color", "yellow");
$(".t1_t_x1").css("background-color", "yellow");
}, function () {
$(this).css("background-color", "white");
$(".t1_t_x1").css("background-color", "white");
}
);
// and keep adding code here if there are more tables
}
这也会导致大量的html代码,例如第一个表:
现在我正在重新设计网站,想知道有没有更有效的方法来实现这一目标?
如果你想看看,请链接到我的site
【问题讨论】:
标签: javascript text hover highlight