asp.net gridview 停止 header 和页脚在鼠标悬停时改变颜色
asp.net gridview stop header and footer from changing color on mouseover
我正在使用以下 jquery 脚本来突出显示 asp.net 网格视图中的每一行并且工作正常。
然而,header 和网格的页脚也会在鼠标悬停时改变颜色,这显然是我不希望发生的。
知道我还需要在脚本中插入什么来阻止网格 header/footer 改变颜色吗?
谢谢
$("table.STD_GridView tr").mouseover(function (event) {
var color = $(this).css("background-color");
$(this).css("background", "#f6f6f6");
$(this).bind("mouseout", function () {
$(this).css("background", color);
})
}
修正案:
这里是一些代码(header 相关)创建:
<th align="left" scope="col"><a href="javascript:__doPostBack('GridView1','Sort$VF')" style="color:White;">Validity</a></th>
网格视图允许您将页眉和页脚的样式设置为与数据行分开,数据行本身也可以设置样式。通过样式我的意思是屁股一个 class 名字。例如:
<tbody>
<tr class="gvHeaderStyle" ></tr>
<tr class="gvRowStyle" ></tr>
<tr class="gvAlternatingRowStyle"></tr>
<tr class="gvFooterStyle"></tr>
</tbody>
做这样的事情应该是一件简单的事情:
<tbody>
<tr class="gvHeaderStyle" ></tr>
<tr class="gvRowStyle HoverableRow" ></tr>
<tr class="gvAlternatingRowStyle HoverableRow"></tr>
<tr class="gvFooterStyle"></tr>
</tbody>
然后 jquery 为此:
$("table.STD_GridView tr.HoverableRow").mouseover( ...
但在这一点上你可以放弃 jquery 而只做 css 事情:
.HoverableRow {
background-color: <default>;
}
.HoverableRow:hover {
background-color: #F6F6F6
}
我正在使用以下 jquery 脚本来突出显示 asp.net 网格视图中的每一行并且工作正常。 然而,header 和网格的页脚也会在鼠标悬停时改变颜色,这显然是我不希望发生的。
知道我还需要在脚本中插入什么来阻止网格 header/footer 改变颜色吗?
谢谢
$("table.STD_GridView tr").mouseover(function (event) {
var color = $(this).css("background-color");
$(this).css("background", "#f6f6f6");
$(this).bind("mouseout", function () {
$(this).css("background", color);
})
}
修正案:
这里是一些代码(header 相关)创建:
<th align="left" scope="col"><a href="javascript:__doPostBack('GridView1','Sort$VF')" style="color:White;">Validity</a></th>
网格视图允许您将页眉和页脚的样式设置为与数据行分开,数据行本身也可以设置样式。通过样式我的意思是屁股一个 class 名字。例如:
<tbody>
<tr class="gvHeaderStyle" ></tr>
<tr class="gvRowStyle" ></tr>
<tr class="gvAlternatingRowStyle"></tr>
<tr class="gvFooterStyle"></tr>
</tbody>
做这样的事情应该是一件简单的事情:
<tbody>
<tr class="gvHeaderStyle" ></tr>
<tr class="gvRowStyle HoverableRow" ></tr>
<tr class="gvAlternatingRowStyle HoverableRow"></tr>
<tr class="gvFooterStyle"></tr>
</tbody>
然后 jquery 为此:
$("table.STD_GridView tr.HoverableRow").mouseover( ...
但在这一点上你可以放弃 jquery 而只做 css 事情:
.HoverableRow {
background-color: <default>;
}
.HoverableRow:hover {
background-color: #F6F6F6
}