无法使用pageX和pageY取消绑定mousemove

时间:2012-05-14 23:52:30

标签: jquery mousemove mousedown mouseup

var mouseStillDown = false;
$(".grab").mousedown(function(e) {
        mouseStillDown=true;
        getLocation();
    }).mouseup(function(e) {
        mouseStillDown = false;
        getLocation();
    });

if(mouseStillDown) {
$("#image_360").bind("mousemove", function(e){
     $("#location").text("e.pageX: " + e.pageX + ", e.pageY: " + e.pageY);
});
}

else if(!mouseStillDown) {
    $("#image_360").unbind("mousemove", function(e){
     $("#location").text("removed location");
    });
}

即使我有未绑定的鼠标移动,我仍然可以使用id=location

在我的div上显示带有pageX和pageY的文本

1 个答案:

答案 0 :(得分:5)

应为$("#image_360").unbind("mousemove");

http://api.jquery.com/unbind/