How To Disable Text Selection in HTML/CSS & JQuery?

Disable text selection HTML – Query : – How to disable text selection on html web page using JQuery & CSS? – To disable the text selection in HTML we need to give user-select property value as none.

Disable text selection HTML CSS & jQuery Example

The jQuery method will start by adding the unselectable attribute to your DOM Element.

Example 1 – Disable text selection on web page in HTML using CSS

Disable text selection HTML using CSS

<!DOCTYPE html>
<html>
<head>
   <title>disable selection of text on web page - Pakainfo.com</title>
   <style type="text/css">
        body{
            user-select: none; /* supported by Chrome and Opera */
            -webkit-user-select: none; /* Safari */
            -khtml-user-select: none; /* Konqueror HTML */
            -moz-user-select: none; /* Firefox */
            -ms-user-select: none; /* Internet Explorer/Edge */
        }
   </style>
</head>
<body>
  
<h3>How to disable text selection on html web page using JQuery?</h3>
  
<p>The YouTube Tag Extractor tool enables you to see and extract YouTube Tags for any video. This is great for improving your own videos.Online tool for Extract youtube tags for analyzing the used tags by other YouTubers for improving the best results of youtube or google searches.The YouTube Tag Extractor extension is a handy way of extracting and revealing meta tags associated with any public video.</p>
  
</body>
</html>

Also Read : How To Disable Previous Date In Html?

Free Live Chat for Any Issue

Example 2 – disable selection of text on web page using JQuery

Disable text selection HTML using jQuery

<!DOCTYPE html>
<html>
<head>
   <title>disable selection of text on web page - Pakainfo.com</title>
   <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
</head>
<body>
  
<h3>How to disable text selection on html web page using JQuery?</h3>
   
<p>The YouTube Tag Extractor tool enables you to see and extract YouTube Tags for any video. This is great for improving your own videos.Online tool for Extract youtube tags for analyzing the used tags by other YouTubers for improving the best results of youtube or google searches.The YouTube Tag Extractor extension is a handy way of extracting and revealing meta tags associated with any public video.</p>
   
<script type="text/javascript">
    (function($){
        $.fn.disableSelection = function() {
            return this
                     .attr('unselectable', 'on')
                     .css('user-select', 'none')
                     .on('selectstart', false);
        };
    })(jQuery);
    
    $('body').disableSelection();
</script>
   
</body>
</html>

Example 3 – disable text selection on website jquery ui

Disable text selection HTML using jquery ui

<!DOCTYPE html>
<html>
<head>
   <title>disable text selection on website jquery - Pakainfo.com</title>
   <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
   <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
</head>
<body>
   
<h3>How to disable text selection on html web page using JQuery?</h3>
   
<p>The YouTube Tag Extractor tool enables you to see and extract YouTube Tags for any video. This is great for improving your own videos.Online tool for Extract youtube tags for analyzing the used tags by other YouTubers for improving the best results of youtube or google searches.The YouTube Tag Extractor extension is a handy way of extracting and revealing meta tags associated with any public video.</p>
   
<script type="text/javascript">
    $('body').disableSelection();
</script>
   
</body>
</html>