使用JQuery和IE在悬停时高亮显示表行-所有版本

Table row highlight on hover using JQuery with IE- all versions

本文关键字:显示 -所 版本 高亮 JQuery IE 悬停 使用      更新时间:2023-09-26

我在jsp页面中有一个表,它有很多行和列,我想让访问者在我的页面上保持定向,当他们在行或列上移动鼠标时,应该用不同的背景色突出显示。我的**hover funtionality**代码在其他浏览器上运行良好,比如chrome、firefox,而不是IE,我需要保持content="IE-5"

这是我的代码:

<meta http-equiv="X-UA-Compatible" content="IE=5" />
<script type="text/javascript"
src="javascripts/jquery/jquery-1.5.1.min.js"></script>
<script type="text/javascript"
src="javascripts/jquery/jquery-ui-1.8.12.custom.min.js"></script>

$(document).ready(function() {
 $('#reportDashBoardTable tr').hover(
    function () {
        $(this).addClass('hover');
    },
    function () {
        $(this).removeClass('hover');
    }
  );
});
 <style type="text/css">
    .hover { background-color:#B0C4DE; }
 </<style>

我如何为IE所有版本做到这一点?

提前感谢!

Anand

为什么不使用CSS?几乎所有IE版本都应该支持它(除了3以下的所有版本)

#reportDashBoardTable :hover { background-color:#B0C4DE; }

我们可以很容易地使用css来实现这个

<style type="text/css">
    table tr:hover {
        background-color: red;
    }
</style>

希望这能帮助