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

问题描述 投票:3回答:1
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");
    });
}

即使我有未绑定的mousemove,我仍然得到带有pageX和pageY的文本显示在我的div上与id=location

jquery mousemove mousedown mouseup
1个回答
6
投票

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

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

© www.soinside.com 2019 - 2024. All rights reserved.