DisableSelection for everything except input [type = text]

I want to use the jQuery function "disableSelection ()" because I have a lot of drag and drop on pages, but I don’t want to turn off selection on input boxes, just the rest.

I tried

$('body').disableSelection(); $('input').enableSelection(); $('body').not('input').disableSelection(); 

still DISABLES ALL ON THE PAGE. Thanks.

+4
source share
2 answers

WITH

 $('body').not('input').disableSelection(); 

Disable selection in every body instance that is not input . Since the body is not an input, it will simply disable the selection on the body.

Try the following:

 $('body *').not(':has(input)').not('input').disableSelection(); 

However, like other people, this indicated that it was probably a rather useless disabling of the selection of things that were not dragged in the first place. Therefore, perhaps you should replace body with .drag or, nevertheless, you can select all the objects that are being dragged (keeping the rest of the function the same).

+9
source

I do not think disableSelection will work for entering text fields. This is useful for creating text elements or elements containing text, not text. For example, if you have a draggable item, you may not need to select text when the user drags the item.

0
source

All Articles