移动端页面中,长按可选中文本;但有时候为了更好地用户体验需禁用此功能。
方法一:
* {
-webkit-user-select:none;
-moz-user-select:none;
-ms-user-select:none;
user-select:none;
}
注:此方法会带来以下问题--
问题一:这样会让iOS的input框无法聚焦
解决方案:
input{-webkit-user-select:auto;}
问题二:如果需要长按发送语音,禁用长按之后,无法长按发送语音
解决方案:
<div class="voice-speak" ontouchstart="return false;" style="display: none" id="startRecord"><span>按住说话</span></div>
方法二:
div { pointer-events: none;}
方法三:
window.ontouchstart = function(e) { e.preventDefault(); };