开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜