How do I make it so that when I double click on a div, it doesn't select a word?

I want to double click on a div, but now it "selects" / highlights the word. How to do this to prevent this from happening?

I tried:

$(this).hide().show()

and 

$(this).blur()

      

But it still emphasizes the word.

+2


a source to share


1 answer


You can prevent the element from being selected in most browsers like:

elem.onselectstart = function() { return false; }; 
elem.unselectable = "on"; 
$(elem).css({ "-moz-user-select": 'none', "-webkit-user-select": 'none' }); 

      



You can try doing this in an event click

and cancel it after one or two seconds with setTimeout

.

+4


a source







All Articles