Prevents texts being selectable in Jquery

So in some situations it is needed to prevent user from selecting text in web page.

So it will play nice in some situations like drag and drop.

So it can be done using Jquery.


$('p').attr('unselectable', 'on')
.css('user-select', 'none')
.on('selectstart', false);

Code pen

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s