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.
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.
Share Improve this question edited Aug 18, 2011 at 14:57 Tim Joyce asked Aug 18, 2011 at 14:49 Tim JoyceTim Joyce 4,5176 gold badges36 silver badges50 bronze badges 6- What does "still no luck" mean? – Anthony Grist Commented Aug 18, 2011 at 14:53
- it means, I tried what I said I tried and had no luck. – Tim Joyce Commented Aug 18, 2011 at 14:54
- @Tim looking and no luck is not question buddy . Tell what happend what error you got what is not working – zod Commented Aug 18, 2011 at 14:55
- I know what the term means in general; I don't know what it means in this particular case. You need to be specific about how those code snippets didn't work. What results do you get? Does it disable selection on everything? On nothing? – Anthony Grist Commented Aug 18, 2011 at 14:55
- it's not a big deal, you just needed to ask and not be cryptic about your question either... – Tim Joyce Commented Aug 18, 2011 at 14:59
2 Answers
Reset to default 9With
$('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).
I dont think so disableSelection
will work for input textboxes. It's useful for making text elements, or elements that contain text, not text-selectable. For example, if you have a draggable element, you may not want text selection to occur when the user goes to drag the element.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744673467a4587186.html
评论列表(0条)