码迷,mamicode.com
首页 > 其他好文 > 详细

拖拽示例

时间:2018-11-23 18:30:30      阅读:187      评论:0      收藏:0      [点我收藏+]

标签:spl   class   style   idt   bin   cli   charset   ack   UNC   

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="js/jquery-1.9.1.min.js"></script>
</head>
<body>
<button class="button">开始</button>
<button class="button">关闭</button>
<button class="button">注册</button>

<div id="con" style="width:500px;height:500px;background: yellow;margin-top: 100px"></div>
<script>
var moveItem=
$(".button").bind("mousedown",function(event){
$("#moveId").remove()
moveItem= $(this).clone();
moveItem.attr("id","moveId")
$("body").append(moveItem)
moveItem.css("left",event.clientX+2).css("top",event.clientY+2);
moveItem.css("opacity","0.5").css("position","fixed").css("point-events","none");
})
$("#con").bind("mouseup",function(event){
$(this).append(moveItem)
moveItem.css("opacity","1").css("position","static");
moveItem.attr("id","")
moveItem.css("display","inline-block");
})

$(document).bind("mousemove",function(event){
moveItem.css("left",event.clientX+2).css("top",event.clientY+2);
})
$(document).bind("mouseup",function(event){
$("#moveId").remove()
})
</script>
</body>
</html>

拖拽示例

标签:spl   class   style   idt   bin   cli   charset   ack   UNC   

原文地址:https://www.cnblogs.com/liuhao-web/p/10008854.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!