html 禁止選中文字的方法


.noselect {

-webkit-touch-callout: none; /* iOS Safari */

-webkit-user-select: none; /* Chrome/Safari/Opera */

-khtml-user-select: none; /* Konqueror */

-moz-user-select: none; /* Firefox */

-ms-user-select: none; /* Internet Explorer/Edge */

user-select: none; /* Non-prefixed version, currently

not supported by any browser */

}
<div class="reduce noselect" unselectable="on">-</div>     

 

 

在 IE < 10 和Opera < 15中我們需要在需要禁止選中的元素上面添加一個屬性

unselectable="on",否則可能不會生效哦~不過現代瀏覽器如果不是非得兼容一些老的瀏覽器也可以不加。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM