JavaScript图片跟着鼠标飞

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <style>
        img {
            position: absolute;
        }
    </style>
</head>
<body>
<img src="images/tianshi.gif" alt="" id="im"/>
<script src="common.js"></script>
<script>
    //鼠标在页面中移动,图片跟着鼠标动
    document.onmousemove = function (e) {
        //鼠标移动的横纵坐标
        //可视区域的横坐标
        my$("im").style.left = e.clientX + "px";
        //可视区域的纵坐标
        my$("im").style.top = e.clientY + "px";
    };
</script>
</body>
</html>

 

posted @ 2018-08-10 17:00  {颜逸}  阅读(340)  评论(0编辑  收藏  举报