How to disable text selection using jQuery?

Hello Guys ,

Your solution by JS


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);


Your Solution by CSS


#csszilla
{
  -moz-user-select: none;
  -khtml-user-select: none;
  -webkit-user-select: none;
  user-select: none;
}

Comments

Popular posts from this blog