var f = true; $elem.mousedown = function () { f = false } $elem.mouseup = function () { f = true } $elem.mousemove(function () { if(f)myfunc) }