Breaking News

【JavaScript】變色表格示例



<html>
    <head>
        <title>變色表格示例</title>
                <script language="javascript">
                    function changeColor(row)
                        {
                            document.getElementById(row).style.backgroundColor='#CCCCFF';
                        }                        
                         function resetColor(row)
                        {
                            document.getElementById(row).style.backgroundColor='';
                        }
                </script>
    </head>
    <body>
    <table width="200" border="1" cellspacing="1" cellpadding="1">
     <tr>
        <th>學校</th>
        <th >專業</th>
        <th>人數</th>
     </tr>
     <tr align="center" id="row1" onMouseOver="changeColor('row1')" onMouseOut="resetColor('row1')">
        <td>北大</td>
        <td>法律</td>
        <td>2000</td>
     </tr> 
    <tr align="center" id="row2" onMouseOver="changeColor('row2')" onMouseOut="resetColor('row2')"> 
       <td>清華</td>
       <td>計算機</td>
       <td>5000</td>
    </tr>
         <tr align="center" id="row3" onMouseOver="changeColor('row3')" onMouseOut="resetColor('row3')"> 
       <td>人大</td>
       <td>經濟</td>
       <td>6000</td>
    </tr>
</table>
</body>
</html>



沒有留言