除输入[type = text]之外的所有内容的disableSelection [英] disableSelection on everything except input[type=text]

查看:62
本文介绍了除输入[type = text]之外的所有内容的disableSelection的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望使用jQuery的disableSelection()函数,因为我在页面上有很多拖放但我不想禁用输入框上的选择,只是其他一切。

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.

我试过

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

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

仍然在页面上禁用所有内容。谢谢。

still DISABLES EVERYTHING ON THE PAGE. Thank you.

推荐答案

使用

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

您在 body 的每个实例上禁用选择这不是输入。由于正文不是输入,因此只会禁用正文选择。

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.

试试这个:

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

然而,正如其他人所指出的那样,禁止选择不可拖动的东西可能相当无用第一名。所以也许你应该用 .drag 替换 body ,或者你可以选择所有可拖动的对象(保留其余的)功能相同)。

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

这篇关于除输入[type = text]之外的所有内容的disableSelection的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆