a1_"+i+".color="#ff0000"; 这个东西写进去之后颜色改变不了,但是如果是写a1_1的话颜色可以正常改变,请教高手指点如何才能解决这个问题

解决方案 »

  1.   

    document.getElementById("a1_"+i).style.color=="#ff0000";
      

  2.   

    给每一<tr>设上个id
    <tr id="tr_1">
      if(t_error){
         alert("第"+i+"行问题没有填写!");
         document.getElementById("tr_" + i).bgColor = "#ff0000";
         document.getElementById("tr_" + i).focus();
      }else {
      document.getElementById("tr_" + i).bgColor = "#ffffff";
    }
      

  3.   

    我做了下测试
    还是用2楼的好<script>
    function bianse() {
        var col = document.getElementById("a1").style.color;
        if(col == 'red') {
    document.getElementById("a1").style.color = 'blue';
        }
        if(col == 'blue' || col == '') {
    document.getElementById("a1").style.color = 'red';
        }
    }
    </script>
    <body>
    <font id="a1">大家好</font>
    <a href="#" onclick="bianse();">变色</a>
    </body>这段代码是没有问题的
    你可以测试一下