pas*_*tgt 3 jquery html-table selection textselection
我有一个基本的表,像这样:
<table>
<tbody>
<tr>
<td>Column 1</td>
<td>Column 2</td>
</tr>
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
在行上我有一个双击函数与jQuery:
$('tr').live('dblclick',function(){
dosomething();
return false;
});
Run Code Online (Sandbox Code Playgroud)
我还有一个名为tablednd的插件,它在行上使用mousedown/up函数.双击会导致单元格上的文本选择.
我怎么能阻止这个?
ale*_*lex 10
您不能使用select()
事件,因为它仅限于输入元素.
相反,试试preventDefault()
这个selectstart
活动......
$('tr').bind('selectstart', function(event) {
event.preventDefault();
});
Run Code Online (Sandbox Code Playgroud)
或者,您可以使用CSS ...
tr {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
Run Code Online (Sandbox Code Playgroud)