var id = this.src.match(/\/?\w+\./ig)[0].replace(/[\/\.]/ig,'');
var _move = false;
var _x,_y;//鼠标离控件左上角的相对位置
$(".right-tr").click(function(){
//alert("click");//点击(松开后触发)
}).mousedown(function(e){
_move = true;
_x = e.pageX-parseInt($("#"+id).css("left"));
_y = e.pageY-parseInt($("#"+id).css("top"));
$("#"+id).fadeTo(20, 0.5);//点击后开始拖动并透明显示
});
$(document).mousemove(function(e){
if(_move){
var x=e.pageX-_x;//移动时根据鼠标位置计算控件左上角的绝对位置
var y=e.pageY-_y;
$("#"+id).css({top:y,left:x});//控件新位置
}
}).mouseup(function(){
_move=false;
$("#"+id).fadeTo("fast", 1);//松开鼠标后停止移动并恢复成不透明
return false;
});
div拖拽,drag
最新推荐文章于 2024-01-11 11:07:44 发布