表格table隔行換色以及點擊整行變色

//表格table隔行換色以及點擊整行變色
function senfe(o, a, b, c, d) {
    if (document.getElementById(o) != null) {
        var t = document.getElementById(o).getElementsByTagName("tr");
        for (var i = 0; i < t.length; i++) {
            t[i].style.backgroundColor = (t[i].sectionRowIndex % 2 == 0) ? a : b;
            t[i].onclick = function() {
                if (this.x != "1") {
                    this.x = "1";
                    this.style.backgroundColor = d;
                } else {
                    this.x = "0";
                    this.style.backgroundColor = (this.sectionRowIndex % 2 == 0) ? a : b;
                }
            }
            t[i].onmouseover = function() {
                if (this.x != "1") this.style.backgroundColor = c;
            }
            t[i].onmouseout = function() {
                if (this.x != "1") this.style.backgroundColor = (this.sectionRowIndex % 2 == 0) ? a : b;
            }
        }
    }
}
 //senfe("表格名稱","奇數行背景","偶數行背景","鼠標經過背景","點擊後背景");
//  senfe("MyGrid1", "#f8fbfc", "#e5f1f4", "#ecfbd4", "#bce774");

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章