Reputation: 4272
Start
$(document).on('mousemove', "#id", EVENT);
Disable
$(document).off('mousemove', "#id");
I have tried...
$(document).off('mousemove', "#id", EVENT);
$("#id").unbind('mousemove');
Exact Functions
$(document).on('click', "#id", function (e) {
$(document).on('mousemove', "#id", EVENT);
});
$(document).on('mouseup', function () {
console.log('test');
$(document).off('mousemove', "#id");
});
What am I doing wrong?
Upvotes: 2
Views: 567
Reputation: 388416
Use mousedown instead of click since click
is fired after 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);
});
Demo: Fiddle
Upvotes: 7