如何防止在选择

问题描述:

我使用JQuery用户界面可选择一个表的表,当我使用多选择用Ctrl我有以下问题:如何防止在选择

enter image description here

我怎么能防止原单选择在表中保持JQuery功能的HTML中?

我已经尝试使用表user-select: none;,但它没有奏效!

任何帮助!

对于完全跨浏览器兼容的解决方案,请随时使用my jQuery noSelect plugin。这里有一个通用演示:http://mathiasbynens.be/demo/noselect

但是你可以使用这样的:

$('table').noSelect(); 
+0

大,非常感谢你。 – Homam 2011-04-21 11:24:44

user-select并非所有浏览器都完全支持。不要依赖这个功能。

没有统一的方法来让项目不可选,这是跨浏览器,但是,每个浏览器似乎都有它自己的方式来实现这一点。
Chrome和Firefox将这些添加到css中:
-webkit-user-select:none;
-moz-user-select:none;
user-select:none;

最后一个适用于Opera,但我不确定。至于IE在HTML标签本身上添加'unselectable ='on'',如<input id="i1" unselectable="on" ..etc