Created
September 20, 2011 11:42
-
-
Save somebox/1228913 to your computer and use it in GitHub Desktop.
jQuery snippet to make page elements unselectable (disable highlights)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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
Note that this function is part of jQueryUI (used for Sortable), but it is still "undocumented" as far as I can tell.