abcdefghjiklmn 2022-03-30 17:12 采纳率: 40%
浏览 33

我用jq写了个脚本想实现:鼠标悬浮在页面表格中背景色为灰色的行,变更其背景色

我写了个脚本如下:
if($(".x-table tr").css('style') == "background-color:grey") {
$(this).mouseover(function () {
$(this).css("background-color","yellow");
}).mouseout(function () {
$(this).css("background-color","grey");
});}
但是执行这个脚本后,并没有生效,请问有人知道是哪里出问题了吗?我怀疑是不是“”选中背景色为灰色的行“”这个命令有问题,但我不知道咋修改。
页面的表格是灰白相间的,所以只能分开设置鼠标悬浮变更背景色:
if($(".x-table tr").css('style') == "background-color:grey") {
$(this).mouseover(function () {
$(this).css("background-color","yellow");
}).mouseout(function () {
$(this).css("background-color","grey");
});}
else if($(".x-table tr").css('style') == "background-color:white") {
$(this).mouseover(function () {
$(this).css("background-color","yellow");
}).mouseout(function () {
$(this).css("background-color","white");
});}
但是执行第一个if的时候就不行了。

  • 写回答

3条回答 默认 最新

  • 面向百度编程cv 2022-03-30 17:21
    关注

    不是这样判断的

    评论

报告相同问题?

问题事件

  • 创建了问题 3月30日