一样不行。
我甚至在页面中放一个BUTTON,在ONCLICK事件中写上执行SetColor('tRY','#fcfcf3','#fcfcf3','#ffff66','#ffff33'); ,还是不行,郁闷

解决方案 »

  1.   

    用css
    this.style.backgroundColor
    |
    |
    this.className=""//設置css
      

  2.   

      t[i].onmouseover=function(){
       if(this.x!="1")
       {//this.style.backgroundColor=c;  
        this.style.className="over";
    alert(this.style.className);
    }
      }修改了下,在onmouseover事件中插入了一个alert用来显示设置的CSS是否成功,结果是正常的,可是颜色还是没变化
      

  3.   

    try:
    function SetColor(o,a,b,c,d){
    //("表格名称","奇数行背景","偶数行背景","鼠hマ~ヌ諸w景","点炅后背景");
    var t=document.getElementById(o).getElementsByTagName("TR");
    for(var i=0;i<t.length;i++){
    (function(){
    var index=i;
    t[index].style.backgroundColor=(t[index].sectionRowIndex%2==0)?a:b;
    t[index].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[index].onmouseover=function(){
    if(this.x!="1"){
    this.style.backgroundColor=c;   
    status=this.sectionRowIndex;
    }
    }
    t[index].onmouseout=function(){
    if(this.x!="1")this.style.backgroundColor=(this.sectionRowIndex%2==0)?a:b;
    }
    })();
    }
    }
      

  4.   

    不用JS也能实现。
    <tr onmouseover="this.className='鼠标滑过的样式'" onmouseout="this.className='鼠标移走后的样式'"></tr>
    我曾经用到过,这个方法虽然有些笨,但还是行得通的,在IE、Firefox、Google Chroma、Opera下都没问题。
      

  5.   

    再解释下,这个函数本身并没有什么问题,因为我把这个函数用在一个非ASP生成的表格中时,是行的通的,
    只是对ASP生成的表格行没有起到作用。
      

  6.   

    是很奇怪,加个断点看一下用asp生成的tr有没有被getElementsByTagName("TR");取到吧?
      

  7.   

    取到了,看  status=this.sectionRowIndex;
    这句就是为了判断的,事实证明,当鼠标在行中划过时,状态栏里面确实是显示的行号
    还有,在这个ASP页面中这个函数没起作用,但是当将这个显示出来的页面的HTML保存为静态HTML时,又可以使用
      

  8.   


    已经用到js了,hehe 不过这个方法好,定义一下不同样式,便于统一修改
      

  9.   

    jquery 多简单
    $("#id").attr("background","xx");
      

  10.   

    我主要是想和大家一起讨论讨论为什么对ASP生成的行没起到作用。。
      

  11.   

    唉,找到问题了,原来是CSS文件中对TD设置了padding和MARGIN属性造成的原因,不知道这跟backgroundColor属性有什么关系。真是麻烦