我做了一个分页控件,我注意到当点击按钮时,很容易意外地 Select 单个图像和文本.有可能防止这种情况吗?

To clarify selecting I mean highlighting with the mouse. (Try dragging your mouse from one side of the screen to the other.)

如果您试图突出显示此网格中的文本/控件,则无法 Select .这是怎么做到的?

推荐答案

dragging and selecting both initialize on a mouse down event and update on subsequent mouse moves. When you handle the events to begin dragging, or to follow the mouse, cancel the event's bubbling and override the default browser return:

something like this in your begin dragging mousedown and move handlers-

e=e || window.event;
pauseEvent(e);
function pauseEvent(e){
    if(e.stopPropagation) e.stopPropagation();
    if(e.preventDefault) e.preventDefault();
    e.cancelBubble=true;
    e.returnValue=false;
    return false;
}

Jquery相关问答推荐

使用动态类名的gm_addStyle?

无法通过单击从元素获取数据

如何用each替换元素的attr href

jQuery .append() 创建两个元素而不是一个

jQuery 上传进度和 AJAX 文件上传

确定元素是否是其父元素的最后一个子元素

如何以十六进制获取元素的背景 colored颜色 代码?

jquery清除输入默认值

jQuery 库中使用的设计模式

如何在 Slick 轮播项目之间添加空格

JQuery手风琴自动高度问题

用 jQuery 模拟按键

jQuery 序列化不注册复选框

如何在实际图像下载时显示加载图像

将 CSS 应用于 jQuery 对话框按钮

隐藏 div 但保留空白

jQuery:如果页面底部有外部 JS,为什么要使用 document.ready?

变量首字母大写

将数据发布到 JsonP

如何删除集中的 contenteditable pre 周围的边框?