且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何防止在javascript中双击选择文本

更新时间:2023-12-02 11:00:52

您可以使用css禁用文本选择(注意这个将有效禁用所有选择方法,而不仅仅是双击)

You can disable text selection using css (Note that this will effectively disable all selection methods and not just double clicking)

ul li {
   -webkit-touch-callout: none;
   -webkit-user-select: none;
   -khtml-user-select: none;
   -moz-user-select: none;
   -ms-user-select: none;
   user-select: none;
}

http://jsfiddle.net/T3d7v/1/