当前位置:网站首页 > 网站建设教程 > HTML教程 > 正文

html--表格高亮显示

教程管理员 发布于2023-09-29 07:27 HTML教程 127

简介: function changeColor(id,flag){ if(flag=="over"){ document.
<!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>

琼ICP备09004296号-12