欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

禁止选中文字兼容IE、Chrome、FF等

程序员文章站 2023-12-17 09:59:04
代码如下: $(el).attr('unselectable','on') .css({'-moz-user-select':'-moz-n...

代码如下:


$(el).attr('unselectable','on')
.css({'-moz-user-select':'-moz-none',
'-moz-user-select':'none',
'-o-user-select':'none',
'-khtml-user-select':'none', /* you could also put this in a class */
'-webkit-user-select':'none',/* and add the css class here instead */
'-ms-user-select':'none',
'user-select':'none'
}).bind('selectstart', function(){ return false; });


根据上面分析 可以设置 你需要禁止选中文字区域的 css。如:

. 代码如下:


.table {
text-align: center;
vertical-align:middle;
height: 39px;
overflow: hidden;
moz-user-select: -moz-none;
-moz-user-select: none;
-o-user-select:none;
-khtml-user-select:none; /* you could also put this in a class */
-webkit-user-select:none;/* and add the css class here instead */
-ms-user-select:none;
user-select:none;/**禁止选中文字*/
}

上一篇:

下一篇: