jQuery - 用DIV跟随光标 [英] jQuery - Follow the cursor with a DIV

查看:183
本文介绍了jQuery - 用DIV跟随光标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用jQuery使用DIV跟随游标?

How can I use jQuery to follow the cursor with a DIV?

推荐答案

DIV ,但您可以在移动光标时绘制 DIV

You can't follow the cursor with a DIV, but you can draw a DIV when moving the cursor!

$(document).on('mousemove', function(e){
    $('#your_div_id').css({
       left:  e.pageX,
       top:   e.pageY
    });
});

那个div必须离开浮动,所以 position:absolute 应设置。

That div must be off the float, so position: absolute should be set.

这篇关于jQuery - 用DIV跟随光标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆