伊人怎会持宠而骄
希望有人懂你的低头不语、小心翼翼守护你的孩子气
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <style type="text/css">
        .active{
            width: 10px;
            height: 10px;
            position: absolute;
            border-radius: 50%;
        }
    </style>
    <body>
    </body>
</html>
<script src="public.js">
</script>
<script>
    /*
    涉及的事件 :
    onmousedown
    onmousemove : 创建div 并设置div的位置 为鼠标当前位置
    onmouseup : 取消移动
     */
    document.onmousedown = function(e){
        e.preventDefault();
        document.onmousemove = function(e){
            var e = e || event;
            var oDiv = create("div");
            oDiv.className = "active";
            document.body.appendChild(oDiv);
            oDiv.style.backgroundColor = getColor();
            oDiv.style.left = e.pageX + "px";
            oDiv.style.top = e.pageY + "px";
        }
        document.onmouseup = function(){
            document.onmousemove = null;//取消移动
        }
        
        //return false;
    }
</script>
posted on 2019-01-25 13:40  伊人怎会持宠而骄  阅读(77)  评论(0编辑  收藏  举报