Created
July 22, 2013 05:06
-
-
Save WenLiangTseng/6051395 to your computer and use it in GitHub Desktop.
讓滑鼠不能選擇文字(適用於一些 drag and drop 的功能,而非防盜copy)
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
//In jQuery 1.8, this can be done as follows: | |
(function($){ | |
$.fn.disableSelection = function() { | |
return this | |
.attr('unselectable', 'on') | |
.css('user-select', 'none') | |
.on('selectstart', false); | |
}; | |
})(jQuery); | |
//example | |
jQuery('.selector').disableSelection(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment