Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery mouseup not being fired when mousemove on image

Tags:

jquery

mouseup

When you mousedown on an image, move the mouse (mousemove) a little bit and then release (mouseup), mouseup is not fired with jQuery.

jsfiddle: http://jsfiddle.net/kVFTZ/

Why is this? How can I make it work when moving on an image?

like image 997
user1643156 Avatar asked Oct 06 '22 13:10

user1643156


1 Answers

Easy enough to fix. Add event.preventDefault(); to your mousedown function.

jsFiddle example

$(document).on('mousedown', function(event) {
    event.preventDefault();
    $('#info').text('Now move the mouse and then release');
    $('#log').text('mouse down fired');
}).on('mouseup', function() {
    $('#log').text('mouse up fired');
});

like image 111
j08691 Avatar answered Oct 10 '22 01:10

j08691