http://jsbin.com/hejilomola/edit?html,css,js,output
上面是demo.寻指导 。
function mousemove(ev){
if(ev==null) ev=window.event;//IE
// var xx=$alert.style.left=(ev.clientX-x)+"px";
var ff=0;
if($alert.style.left>ff){
$alert.style.left=(ev.clientX-x)+"px";
}
// console.log(xx);
var yy=$alert.style.top=(ev.clientY-y)+"px";
console.log(yy)
}
谢邀
在其他代码不变的情况下,修改拖拽逻辑,楼主试试把这个函数放到你的代码中,应该可以实现你的要求