Jquery实现表格光棒效果

来源:互联网 发布:简单计算器c语言 编辑:程序博客网 时间:2024/05/02 00:44
<script type="text/javascript">        //光棒效果        var _bgColor;  //存放原始的 背景颜色        $(document).ready(function () {            //所有的行鼠标移进时变色            $("tr").hover(function () {                _bgColor = $(this)[0].style.backgroundColor;                $(this).css({ 'background-color': '#f5f5f5', 'font-weight': 'bolder' });            },            //移除还原颜色    function () {        var cssObj = { 'background-color': _bgColor, 'font-weight': '' }        $(this).css(cssObj);    });            //交替行变色            var trs = $("table").find("tr");            for (i = 0; i < trs.length; i++) {                var obj = trs[i];                if (i % 2 == 0)                    obj.style.backgroundColor = "#F5FAFE";            }        });</script>