Skip to content

Instantly share code, notes, and snippets.

@mojaray2k
Created September 12, 2013 07:20
Show Gist options
  • Save mojaray2k/6533949 to your computer and use it in GitHub Desktop.
Save mojaray2k/6533949 to your computer and use it in GitHub Desktop.
In certain situations, you might want to prevent text on the page from being selectable. This is useful when building interfaces that can be dragged or reordered, as you don't want users to select text from the page by accident. Here is a snippet that does this and works in all browsers.
$('p.descr').attr('unselectable','on')
.css('user-select','none')
.on('select-start', false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment