【问题标题】:How to keep the back color of the cell after passing the highlight at the top of that cell?通过单元格顶部的突出显示后如何保持单元格的背面颜色?
【发布时间】:2012-01-16 06:57:39
【问题描述】:

我有一个 GridView,它为某些单元格提供特定的背景颜色,即绿色。现在,我正在使用 JQuery 来修复标题和列。这个 JQuery 有一个荧光笔。现在的问题是当荧光笔在那些有绿色背景的单元格顶部时,绿色背景颜色会消失,并且在荧光笔离开这个单元格后,单元格将没有颜色。

下图显示了问题:

<script type="text/javascript">
            $(document).ready(function () {
                sh_highlightDocument();

                $(".tableDiv").each(function () {
                    var Id = $(this).get(0).id;
                    var maintbheight = 555;
                    var maintbwidth = 900;

                    $("#" + Id + " .FixedTables").fixedTable({
                        width: maintbwidth,
                        height: maintbheight,
                        fixedColumns: 4,
                        classHeader: "fixedHead",
                        classFooter: "fixedFoot",
                        classColumn: "fixedColumn",
                        fixedColumnWidth: 500,
                        outerId: Id,
                        Contentbackcolor: "#FFFFFF",
                        Contenthovercolor: "#99CCFF",
                        fixedColumnbackcolor: "#187BAF",
                        fixedColumnhovercolor: "#99CCFF"
                    });
                });
            });
    </script>

我正在使用这个JQuery FixedTable

【问题讨论】:

  • 你能发布一个你使用的fixedTable插件的链接吗?如果您无法充分利用它的悬停行为来恢复以前的背景颜色,则可能需要修改该插件或找到其他插件。
  • 查看我问题末尾的链接。
  • 没有超级简单的方法可以修改该插件的行为,而无需在源代码中添加一些额外的行以在鼠标悬停时保存现有背景颜色(使用$.data())并在鼠标悬停时恢复它。

标签: c# jquery asp.net css gridview


【解决方案1】:

在更改之前,您需要将单元格的现有属性存储在变量中。

我不是 100% 使用 JQuery 语法,但如果你可以这样做:

(悬停) var oldColor = cell.Style["background-color"];

cell.Style["background-color"] = 绿色;

(onMouseOut) cell.Style["background-color"] = oldColor;

这应该为您提供所需的功能

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-21
    • 1970-01-01
    • 1970-01-01
    • 2019-04-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多