Skip to content

Instantly share code, notes, and snippets.

@murilobr
Created September 8, 2015 20:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save murilobr/def47f3628d4d2ecd66b to your computer and use it in GitHub Desktop.
Save murilobr/def47f3628d4d2ecd66b to your computer and use it in GitHub Desktop.
Prevent text selection jquery
$(":not(input,select,textarea)").attr('unselectable', 'on')
.css({'-moz-user-select':'-moz-none',
'-moz-user-select':'none',
'-o-user-select':'none',
'-khtml-user-select':'none', /* you could also put this in a class */
'-webkit-user-select':'none',/* and add the CSS class here instead */
'-ms-user-select':'none',
'user-select':'none'
}).bind('selectstart', function(){ return false; });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment