How can I disable text-selection in webkit browsers when using jQuery UI .draggable?

时光毁灭记忆、已成空白 提交于 2019-12-06 12:24:13

问题


I can't seem to disable text-selection in webkit browsers when using jQuery UI .draggable(). I've tried using the webkit specific css (-webkit-user-select and -webkit-user-drag) in various combinations but haven't had any luck.

Here's a jsfiddle where you can reproduce the problem: http://jsfiddle.net/dmosher/8ZGLR/


回答1:


disableSelection is your friend here.

.disableSelection() is an undocumented (for now) core utility. It's useful for making text elements, or elements that contain text, not text-selectable. For example, if you have a draggable element, you may not want text selection to occur when the user goes to drag the element.

You may want to create a helper so it looks obvious that something is being dragged.

Updated demo



来源:https://stackoverflow.com/questions/4597174/how-can-i-disable-text-selection-in-webkit-browsers-when-using-jquery-ui-dragga

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!