最简单的鼠标拖动,简单的拖拽层
<script>
var xx=0,yy=0;
function a(v)
{
xx=event.x-v.offsetLeft;
yy=event.y-v.offsetTop;
}
function b(v)
{
v.style.left=event.x-xx;
v.style.top=event.y-yy;
}
</script>
<img id="img" src="www.baidu.com/img/baidu_logo.gif" style="position:absolute;" ondragstart="a(this);" ondrag="b(this);" >
var xx=0,yy=0;
function a(v)
{
xx=event.x-v.offsetLeft;
yy=event.y-v.offsetTop;
}
function b(v)
{
v.style.left=event.x-xx;
v.style.top=event.y-yy;
}
</script>
<img id="img" src="www.baidu.com/img/baidu_logo.gif" style="position:absolute;" ondragstart="a(this);" ondrag="b(this);" >