How do I make it so that when I double click on a div, it doesn't select the word?
I want to开发者_开发百科 double click on a div, but right now it "selects"/highlights a word. How do I make it so that this doesn't happen?
I tried:
$(this).hide().show()
and
$(this).blur()
But it still highlights the word.
You can prevent an element from being selected in most browsers like this:
elem.onselectstart = function() { return false; };
elem.unselectable = "on";
$(elem).css({ "-moz-user-select": 'none', "-webkit-user-select": 'none' });
You could try doing that in the click
event and undoing it one or two seconds later using setTimeout
.
精彩评论