Skip to content

Instantly share code, notes, and snippets.

@qizhihere
Created June 23, 2015 13:41
Show Gist options
  • Save qizhihere/bc8112ac4afe36a85eb0 to your computer and use it in GitHub Desktop.
Save qizhihere/bc8112ac4afe36a85eb0 to your computer and use it in GitHub Desktop.
disable double click text selection using jQuery
$.fn.disableSelection = function() {
return this.attr('unselectable', 'on')
.css({
'-moz-user-select': '-moz-none',
'-moz-user-select': 'none',
'-o-user-select': 'none',
'-khtml-user-select': 'none',
'-webkit-user-select': 'none',
'-ms-user-select': 'none',
'user-select': 'none'
})
.bind('selectstart', false);
};
// an example
$('tbody tr').disableSelection();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment