How to Disable Text Selection on an HTML Web Page using JQuery?

disable-text-selection-javascript

Disable select and copy-paste on the website with Jquery which prevents content from being stolen from your website with unselectable HTML attribute, CSS user-selectable property, and JavaScript select start event.

disable text selection jquery, enable text selection javascript, how to disable text selection in web page, disable text selection css, disable text selection html, disable text selection in input field

How to make use of it:

1. Copy and paste the next JS snippets after jQuery.

<script src="/path/to/cdn/jquery.slim.min.js"></script>
(function($){
  $.fn.disableSelection = function() {
    return this
    .attr('unselectable', 'on')
    .css('user-select', 'none')
    .on('selectstart', false);
  };
})(jQuery);

2. Disable text choice on the whole web page.

$(function(){
  $('body').disableSelection();
});

3. Or on a selected container.

$(function(){
  $(''.container').disableSelection();
});

Prevent Content Theft By Disabling Text Selection, diable-selection tool Plugin/Github, how to protect your website content from being copied, how to disable text selection


See Demo And Download

Official Website(habeebuddinhuzaifa): Click Here

This superior jQuery/javascript plugin is developed by habeebuddinhuzaifa. For extra Advanced usage, please go to the official website.

Share