html--表格高亮显示

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <script type="text/javascript">
            function changeColor(id,flag){
                if(flag=="over"){
                    document.getElementById(id).style.backgroundColor="red";
                }else if(flag=="out"){
                    document.getElementById(id).style.backgroundColor="white";
                }
            }
        </script>
    </head>
    <body>
        <table border="1px" width="100px" height="100px" align="center">
            <thead>
                <tr onmouseover="changeColor('t1','over')" onmouseout="changeColor('t1','out')" id="t1">
                    <th>d</th>
                    <th>dx</th>
                </tr>
            </thead>
            <tbody>
                <tr onmouseover="changeColor('t2','over')" onmouseout="changeColor('t2','out')" id="t2">
                    <td>s1</td>
                    <td>s2</td>
                </tr>
                <<tr onmouseover="changeColor('t3','over')" onmouseout="changeColor('t3','out')" id="t3">
                    <td>s3</td>
                    <td>s4</td>
                </tr>
            </tbody>
        <table>
    </body>
</html>

猜你喜欢

转载自blog.csdn.net/qq_38409944/article/details/80340436