Skip to content

Instantly share code, notes, and snippets.

@azu
Created December 9, 2011 08:10
Show Gist options
  • Save azu/1450698 to your computer and use it in GitHub Desktop.
Save azu/1450698 to your computer and use it in GitHub Desktop.
要素を選択範囲にできないようにする
(function ($) {
$.fn.disableSelection = function () {
return this.each(function () {
$(this).attr('unselectable', 'on')
.css({'-moz-user-select':'none',
'-o-user-select':'none',
'-khtml-user-select':'none',
'-webkit-user-select':'none',
'-ms-user-select':'none',
'user-select':'none'})
.each(function () {
$(this).attr('unselectable', 'on')
.bind('selectstart', function () {
return false;
});
});
});
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment