Skip to content

Instantly share code, notes, and snippets.

@oneblackcrayon
Forked from somebox/jquery.disable.js
Created January 1, 2017 06:24
Show Gist options
  • Save oneblackcrayon/d351f5830f5dee3e01c7acb407cbac3a to your computer and use it in GitHub Desktop.
Save oneblackcrayon/d351f5830f5dee3e01c7acb407cbac3a to your computer and use it in GitHub Desktop.
jQuery snippet to make page elements unselectable (disable highlights)
/* disable user selections */
jQuery.fn.disableSelection = function(){
$(this).each(function(){
$(this).attr('unselectable', 'on')
.css('-moz-user-select', 'none')
.each(function() {
this.onselectstart = function() { return false; };
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment