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

前端技术 2023/09/06 JavaScript
复制代码 代码如下:

$(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;/**禁止选中文字*/
}

本文地址:https://www.stayed.cn/item/15724

转载请注明出处。

本站部分内容来源于网络,如侵犯到您的权益,请 联系我

我的博客

人生若只如初见,何事秋风悲画扇。