分享到(事件冒泡实例)

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <style>
            #div1{
                width: 100px;
                height: 200px;
                background: red;
                position: absolute;
                left: 0;
                top: 100px;
            }
            #div2{
                width: 30px;
                height: 60px;
                background: black;
                position: absolute;
                right: -30px;
                top: 70px;
                color: #fff;
                text-align: center;
            }
        </style>
        <script>
            window.onload=function(){
                var oDiv=document.getElementById("div1");
                
                oDiv.onmouseover=function(){
                    this.style.left='0px';
                }
                oDiv.onmouseout=function(){
                    this.style.left='-100px';
                }
            }
        </script>
    </head>
    <body>
        <div id="div1">
            <div id="div2">分享到</div>
        </div>
    </body>
</html>

 

posted @ 2018-11-28 10:38  webxy  阅读(181)  评论(0编辑  收藏  举报