问题是这样的:
我现在用javasctipt函数生成了一个表格 我还需要设置一下行的样式
function add()
{
     var table = document.getElementById("myTable");
     var rows = table.rows;
     var c1,c2,c3,c4,c5,c6,c7,c8;
     var newRow = table.insertRow(rows.length);
     newRow.className = "trbg1";  //这里我设置了行的样式 这个效果有
      //下面我想设置一下onMouseOver和onMouseOut时的样式 请问这里我该怎么写呢
     不知道该如何获得对象的事件来设置.
     其他代码省略...
}
请各位高手帮忙解决一下.万分感谢.在线等.....

解决方案 »

  1.   

    newRow.onmouseover=function(){
    this.className="your class name";
    }
    onmouseout类似
      

  2.   


    <HTML>
    <HEAD>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <TITLE>Daily Report Frame</TITLE>
    <style>
    .ttt{
    background-color:#09F;
    }
    .ddd{
    background-color:#0F6;
    }
    </style>
    <script>
    function add()
    {
        var table = document.getElementById("myTable");
        var rows = table.rows;
        var newRow = table.insertRow(rows.length);
        newRow.className = "ttt"; 
    var td = newRow.insertCell(0);
    td.innerHTML = "aaa";
    newRow.onmouseover = function(){this.className="ddd";};
    newRow.onmouseout = function(){this.className="ttt";};

    function func(){
    for(var i=0;i<10;i++){
    add();
    }
    }
    </script>
    </HEAD>
    <body onLoad="func()">
    <table id="myTable">
    <tr>
         <td>111</td>
        </tr>
    </table>
    </body>
    </HTML>