I am looking to use jQuery's "disableSelection()" function because I have a lot of drag and drop on the pages but I do not want to disable selection on input boxes, just everything else.
I have tried
$('body').disableSelection(); $('input').enableSelection();
$('body').not('input').disableSelection();
still DISABLES EVERYTHING ON THE PAGE. Thank you.
With
$('body').not('input').disableSelection();
You disable selection on every instance of body
that is not an input
. Since body is not an input this will just disable selection on body.
Try this:
$('body *').not(':has(input)').not('input').disableSelection();
However, like other people pointed out it's probably pretty useless disabling selection on things that aren't draggable in the first place. So maybe you should replace body
with .drag
or however you can select all the objects that are draggable (keeping the rest of the function the same).
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