2

开始

$(document).on('mousemove', "#id", EVENT);

禁用

$(document).off('mousemove', "#id");

我努力了...

$(document).off('mousemove', "#id", EVENT);
$("#id").unbind('mousemove');

精确函数

$(document).on('click', "#id", function (e) {
    $(document).on('mousemove', "#id", EVENT);
});

$(document).on('mouseup', function () {
    console.log('test');
    $(document).off('mousemove', "#id");
});

我究竟做错了什么?

4

1 回答 1

7

使用mousedown而不是click,因为click在之后触发mouseup

$(document).on('mousedown', "#id", function (e) {
    console.log('register')
    $(document).on('mousemove', "#id", EVENT);
});

$(document).on('mouseup', function () {
    console.log('test');
    $(document).off('mousemove', "#id", EVENT);
});

演示:小提琴

于 2013-05-02T17:07:30.057 回答