Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Reference:</strong></p> <p><a href="http://jsfiddle.net/ebEqu/" rel="noreferrer"><strong>jsFiddle Demo with Plugin</strong></a></p> <p>The above jsFiddle Demo I made uses a Plugin to allow you to <strong><em>prevent any block of text from being selected</em></strong> in <strong>Android</strong> or <strong>iOS</strong> devices (along with desktop browsers too).</p> <p>It's easy to use and here is the sample markup once the jQuery plugin is installed.</p> <p><strong>Sample HTML:</strong></p> <pre><code>&lt;p class="notSelectable"&gt;This text is not selectable&lt;/p&gt; &lt;p&gt; This text is selectable&lt;/p&gt; </code></pre> <p><strong>Sample jQuery:</strong></p> <pre><code>$(document).ready(function(){ $('.notSelectable').disableSelection(); }); </code></pre> <p><strong>Plugin code:</strong></p> <pre><code>$.fn.extend({ disableSelection: function() { this.each(function() { this.onselectstart = function() { return false; }; this.unselectable = "on"; $(this).css('-moz-user-select', 'none'); $(this).css('-webkit-user-select', 'none'); }); return this; } }); </code></pre> <p><strong>Per your message comment:</strong> <em><code>I still need to be able to trigger events (notably, touchstart, touchmove, and touchend) on the elements.</code></em> </p> <p>I would simply would <strong>use a wrapper</strong> that is <strong>not</strong> affected by this plugin, yet it's text-contents are protected using this plugin.</p> <p>To allow interaction with a link in a block of text, you can use <code>span tags</code> for all but the link and add class name <code>.notSelected</code> for those <code>span tags</code> only, thus preserving selection and interaction of the anchors link.</p> <p><strong>Status Update:</strong> This updated <a href="http://jsfiddle.net/ebEqu/1/" rel="noreferrer"><strong>jsFiddle</strong></a> confirms you concern that perhaps other functions may not work when text-selection is disabled. Shown in this updated jsFiddle is jQuery Click Event listener that will fire a Browser Alert for when the Bold Text is clicked on, even if that Bold Text is not text-selectable.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload