oTr.rowIndex % 2 != 0 ? oTr.style.backgroundColor = b ? aBgColor[3] : aBgColor[1] : oTr.style.backgroundColor = b ? aBgColor[2] : aBgColor[0];aBgColor是存放着几个颜色的数组
oTr是TR对象
b是布尔值,

解决方案 »

  1.   

    看得有点晕,这样试下oTr.style.backgroundColor = aBgColor[oTr.rowIndex % 2 ? b ? 3 : 1 : b ? 2 : 0];
      

  2.   

    if(oTr.rowIndex % 2!=0&&oTr.style.backgroundColor = =b)
    {
      ...
    }
    else
    {
    ...
    }
      

  3.   


    oTr.rowIndex % 2 != 0 ? oTr.style.backgroundColor = b ? aBgColor[3] : aBgColor[1] : oTr.style.backgroundColor = b ? aBgColor[2] : aBgColor[0];
    if (oTr.rowIndex % 2 != 0) {
    if (b) {
    oTr.style.backgroundColor = aBgColor[3];
    } else {
    oTr.style.backgroundColor = aBgColor[1];
    }
    } else {
    if (b) {
    oTr.style.backgroundColor = aBgColor[2];
    } else {
    oTr.style.backgroundColor = aBgColor[0];
    }
    }
      

  4.   

    解析成if else就是上面的样子
      

  5.   


    if (oTr.rowIndex % 2 != 0) {
        if (b) {
            oTr.style.backgroundColor = aBgColor[3];
        } else {
            oTr.style.backgroundColor = aBgColor[1];
        }
    } else {
        if (b) {
            oTr.style.backgroundColor = aBgColor[2];
        } else {
            oTr.style.backgroundColor = aBgColor[0];
        }
    }