在我的Web应用程序中,用户有时可能会多次点击同一个按钮,跳过消息和其他内容,导致选中</a>
标签。
因此,我该如何使用JavaScript(jQuery)避免这种情况。
在我的Web应用程序中,用户有时可能会多次点击同一个按钮,跳过消息和其他内容,导致选中</a>
标签。
因此,我该如何使用JavaScript(jQuery)避免这种情况。
您不需要脚本,只需使用以下CSS代码:
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
$(function(){
$.extend($.fn.disableTextSelect = function() {
return this.each(function(){
if($.browser.mozilla){//Firefox
$(this).css('MozUserSelect','none');
}else if($.browser.msie){//IE
$(this).bind('selectstart',function(){return false;});
}else{//Opera, etc.
$(this).mousedown(function(){return false;});
}
});
});
$('.noSelect').disableTextSelect();//No text selection on elements with a class of 'noSelect'
});