The script catches the movement of the cursor while holding the LMB up and down, but not every time correctly. He sees a couple of movements correctly, determines the following movements incorrectly (the mouse goes down - the script shows that upwards, and so they alternate randomly, as far as I noticed), and the first click ignores them altogether. I can not understand why
var pageY = 0; var $debugContainer; $(function () { $debugContainer = $('#debug'); $('.nizina').mousedown(function (event) { $(this).on('mousemove', function (e) { if (pageY) { if (event.pageY > pageY) { $debugContainer.html('Мышка движется вниз'); console.log('Мышка движется вниз'); } else if (event.pageY < pageY) { $debugContainer.html('Мышка движется вверх'); console.log('Мышка движется вверх'); } } pageY = event.pageY; }); }); }); $('.nizina').on('mouseup mouseout', function (e) { $(this).off('mousemove'); }); (changed the code to more suitable for debug) Example here: https://jsfiddle.net/mrvo5896/3/