Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

disableSelection on everything except input[type=text]

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.

like image 823
Tim Joyce Avatar asked Jan 19 '23 22:01

Tim Joyce


1 Answers

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).

like image 144
Kokos Avatar answered Jan 28 '23 19:01

Kokos