4
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");
    });
}

即使我有未绑定的鼠标移动,我仍然会在我的 div 上显示带有 pageX 和 pageY 的文本id=location

4

1 回答 1

6

它应该是$("#image_360").unbind("mousemove");

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

于 2012-05-15T00:05:10.153 回答