JQuery double click but don't select content

I am using the jquery dbclick () function to toggle the highlight of the raw table. The problem I am facing is that whenever I double-click, the contents of the cell are also selected. Is there an easy way to prevent content selection?

My code is:

if ($('.tbl_repeat').length > 0) { $('.tbl_repeat tr').dblclick(function() { $(this).toggleClass('tr_active'); }); } 

Perhaps I didn’t make it clear - I don’t want to turn off the selection of everything together - only with a double click - except for this event, everything else should be selected as usual.

+4
source share
2 answers

You can try to deselect via css on the element that you double click

 .unselectable { -moz-user-select : none; -khtml-user-select : none; -webkit-user-select : none; -o-user-select : none; user-select : none; } 
+10
source

Put the encoding below between them (between the main tags)

 <style> .unselectable { -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; -o-user-select: none; user-select: none; } </style> 

Put it in between (between body tags)

 <p class="unselectable"> your unselectable text here </p> 

Just like that ..

 <!DOCTYPE HTML> <html lang="en-US"> <head> <meta charset="UTF-8"> <title></title> <style> .unselectable { -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; -o-user-select: none; user-select: none; } </style> </head> <body> <p class="unselectable"> <span> your unselectable text here </span><br> <a href="#" onclick="return false;"> your unselectable link here </a></p> </body> </html>​ 
+4
source

All Articles