【发布时间】:2014-09-04 12:25:37
【问题描述】:
我有一个显示信息的表格。表中的一列是注释列。在此注释列中,我使用一些 CSS 和 Jquery 创建了一个工具提示。我遇到的问题是,当我将鼠标悬停在单元格上时,它会正确显示工具提示,但是在将鼠标移开后会从单元格中擦除颜色(变为白色)。我希望它在鼠标移开后保持其颜色,但我不确定如何。
工具提示事件的当前代码(每个注释单元格都有注释类):
$('.note').hover(
function (event) {
$(event.target).css({
"white-space": "normal",
"text-overflow": "clip",
"background-color": "#eeeeee",
"max-width": "200px",
"position": "absolute"
});
}, function (event) {
$(event.target).css({
"white-space": "nowrap",
"text-overflow": "ellipsis",
"background-color": "transparent",
"max-width": "200px",
"position": "static"
});
}
);
【问题讨论】:
-
在css上做解决方案没问题?
-
这是意料之中的,因为您的代码在光标离开元素后将内联 css 添加到元素中。你应该只使用纯 CSS 和 :hover
标签: jquery html css-tables