Disable text selection on iOS and Android devices

Updated . Posted . Visible to the public.

When you double-tap a string of text on an iPhone or iPad a complicated context menu for copying and pasting will appear. This can confuse unexperienced users.

Use the Javascript hack below to disable text selection on mobile devices:

// Deactivating distracting Text Selection:
// from: http://stackoverflow.com/questions/1794220/how-to-disable-mobilesafari-auto-selection
  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');

$(function() {
Henning Koch
Last edit
Source code in this card is licensed under the MIT License.
Posted by Henning Koch to makandra dev (2011-07-14 13:16)