日期:2014-05-17  浏览次数:20552 次

好久没来了 问个简单的JS问题- -不触碰太久了
需求.我有一个动态生存的table 需要实现点击一行变色  点击第2行第一行还原 第2行变色 类推。
代码实现了点击变色 但是点击之后无法还原 希望JS高手帮忙改改。
PS: 不能直接在TR中加入客户端事件 按照下面这个 改 谢谢。

function senfe(o, a, b, c)
{
    var t = document.getElementById(o)
    if (t != null)
    {
        t = t.getElementsByTagName("tr");
        for (var i = 1; i < t.length; i++)
        {
            var bool = true;
            t[i].onclick = function()
            {
                this.x = "0";
                this.style.backgroundColor = (this.sectionRowIndex % 2 == 0) ? a : b;
                this.color = "#ffffff";
                this.style.cursor = "hand";
            }
            t[i].onmouseover = function()
            {
                if (this.x != "1")
                    this.style.cursor = "hand";
            }
        }
    }
}

------解决方案--------------------

var FocusTrNum = -1;