排名
6
文章
6
粉丝
16
评论
8
{{item.articleTitle}}
{{item.blogName}} : {{item.content}}
ICP备案 :渝ICP备18016597号-1
网站信息:2018-2025TNBLOG.NET
技术交流:群号656732739
联系我们:contact@tnblog.net
公网安备:
50010702506256


欢迎加群交流技术

div跟随,就是一个鼠标移动事件
html:
<div id="playbox" class="box"> 不要跟着我 </div>
js:
$(function () { $(document).mousemove(function (event) { $("#playbox").html("x:" + event.pageX + ",y:" + event.pageY); $("#playbox").css("left", event.pageX).css("top", event.pageY); }); });
div拖动
方法1:
$(function () { var isdown = false; $("#mybox").mousedown(function () { isdown = true; }); $(document).mouseup(function () { isdown = false; }); $(document).mousemove(function (event) { if (isdown) { $("#mybox").css("left", event.pageX - $("#mybox").width() / 2).css("top", event.pageY - $("#mybox").height() / 2); } }); });
欢迎加群讨论技术,1群:677373950(满了,可以加,但通过不了),2群:656732739。有需要软件开发,或者学习软件技术的朋友可以和我联系~(Q:815170684)
评价