jQuery 图片随鼠标移动

1.选择一个图片设置一下宽高

<img src="1.gif" class="mouse"  style="width:80px;height:80px;"/>

2.jQuery代码:

 $(function(){
        $(document).mousemove(function (e) {
            //获取图片的相对鼠标的位置
            $(".mouse").css({ 'top': e.pageY, 'left': e.pageX, 'position': 'absolute'});
        });
    });



猜你喜欢

转载自blog.csdn.net/mogul1/article/details/80901827
今日推荐