• 匿名函数和鼠标移入移除事件


    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>改变边框</title>
        <style>
            .def {
                border: 1px solid #ccc;
                margin-right: 120px;
            }
    
            .hover {
                border: 1px solid red;
                margin-right: 120px;
            }
        </style>
        <script>
    //        function over(target) {
    //            target.className = 'hover';
    //        }
    //        function def(target) {
    //            target.className = 'def';
    //        }
            window.onload=function () {
                var img=document.getElementsByTagName('img');//取得所有的图片数组
                for(var i=0;i<img.length;i++){//遍历每一张图片
                    img[i].onmouseover=function(){//每一张图片加一个onmouseover事件
                        this.className='hover';
                    }
                    img[i].onmouseout=function () {
                        this.className='def';
                    }
                }
            }
            
        </script>
    </head>
    <body
    ">
    <table>
        <tr>
            <td><img src="images/new_01.jpg" alt="" class="def"></td>
            <td><img src="images/new_02.jpg" alt="" class="def"></td>
            <td><img src="images/new_03.jpg" alt="" class="def"></td>
        </tr>
    </table>
    </body>
    </html>
  • 相关阅读:
    案例分析
    阅读任务
    准备工作
    课程总结
    十三周总结
    第十二周总结
    第十一周学习总结
    第十周学习总结
    第九周课程总结&实验报告7
    第八周课程学习总结与实验6
  • 原文地址:https://www.cnblogs.com/lwj820876312/p/7058550.html
Copyright © 2020-2023  润新知