使用javascript或jquery禁用鼠标双击 [英] Disable mouse double click using javascript or jquery
问题描述
我有一个表格,其中我有一些文本框,下面有一个表格。当我双击表格行时,它会带我到另一页。
I have a form in which i have some text boxes and below to it there is a table.When i double click on table row it takes me to another page.
现在的问题是,如果我双击文本框也会转到另一个页面,所以,我需要禁用鼠标单击此文本框,并使用tr作为标题和另一个tr数据。当我点击tr标题也它应该不起作用。
Now the problem is if i double click on text boxes also it is going to another page so,i need to disable mouse clicks on this text boxes and also used tr for header and another tr for data.when i click tr header also it should n't work.
注意:
我有很多文本框,所以每次点击一下鼠标禁用不是很好解决。如果单击数据行,双击应该可以工作。
i have many text boxes so making each one double click mouse disabling is n't good solut.If i click row with data alone that double click should work.
推荐答案
添加 class ='myClickDisabledElm'
到所有DOM元素,您希望停止其点击次数。
add a class='myClickDisabledElm'
to all DOM elements whose clicks you want to stop.
<input type="text" class="myClickDisabledElm" />
现在javascript
now javascript
jQuery('.myClickDisabledElm').bind('click',function(e){
e.preventDefault();
})
编辑
因为你更关注双击您可以使用 dblclick
代替点击
Since you are more concerned abt double click you may use dblclick
in place of click
这篇关于使用javascript或jquery禁用鼠标双击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!