I'm trying to do my own drag and drop function using jquery library. But everytime I mousedown on an image, then mousemove, my browser "highlights" or "selects" the image, which disrupts my mousemove operation.
How do I disable the select/highlight? I tried $('img').onselectstart = function() {return false;}
, but that didn't work.
You could prevent the default behaviour of the dragstart
event...
$('img').bind('dragstart', function(event) { event.preventDefault(); });
jsFiddle.
jQuery UI has an undocumented method that it uses to disable browser text selection. You can call it using this syntax:
$('IMG').disableSelection();
Remember that you need to be using jQuery UI (which I assume you are).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With