在我的网络应用程序中,用户有时可以多次单击同一个按钮,跳过消息和事物,导致</a>
被选中。
那么如何使用 Javascript (jQuery) 防止这种情况发生
在我的网络应用程序中,用户有时可以多次单击同一个按钮,跳过消息和事物,导致</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;
这个解决方案对我有用: http ://chris-barr.com/entry/disable_text_selection_with_jquery/
$(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'
});