function SelectRow(objLink)
{
  var obj = objLink;
  var trObj = obj.parentNode.parentNode;
  var tdcount=trObj.childNodes.length;
  for(i=0;i<tdcount;i++)
  {
    if(trObj.childNodes[i]==obj.parentNode)
      trObj.childNodes[i].style.backgroundColor="#FFC";
    else
      trObj.childNodes[i].style.backgroundColor="#FFF";
  }
}ie 6.0 下通过

解决方案 »

  1.   

    因为只有一个被点击,我认为用一个变量来记录比较方便,并且比二楼的计算量小
    如:var buttonOn;
    function SelectRow(objLink)
    {
    if(buttonOn)buttonOn.style.backgroundColor = "";
    buttonOK = objLink; while (buttonOK .tagName!="TD")
    {
    buttonOK =buttonOK .parentElement;
    }
    buttonOK .style.backgroundColor ="#FFC";
    }
      

  2.   

    var obj;
    function SelectRow(objLink)
    {
    if(obj)obj.style.backgroundColor = ""
    obj = objLink; while (obj.tagName!="TD")
    {
    obj=obj.parentElement;
    }
    obj.style.backgroundColor ="#FFC";
    }