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.
Now the problem is if i
If you want to disable any mouse click action use addEventListener(event, function, useCapture) .
Onclick ,call this function.
For more refer here.: https://www.w3schools.com/jsref/met_element_addeventlistener.asp
it should be like this
$('.myTextBox').dblclick(function(e){ e.preventDefault(); })
As said here, use a capture phase event listener:
document.addEventListener( 'dblclick', function(event) {
alert("Double-click disabled!");
event.preventDefault();
event.stopPropagation();
}, true //capturing phase!!
);
add a class='myClickDisabledElm'
to all DOM elements whose clicks you want to stop.
<input type="text" class="myClickDisabledElm" />
now javascript
jQuery('.myClickDisabledElm').bind('click',function(e){
e.preventDefault();
})
Edit
Since you are more concerned abt double click you may use dblclick
in place of click
Got the following code from here
jQuery code to disable double click event on the webpage.
$(document).ready(function(){
$("*").dblclick(function(e){
e.preventDefault();
});
});
Above jQuery code will disable double click event for all the controls on the webpage. If you want to disable for specific control, let's say a button with ID "btnSubmit" then,
$(document).ready(function(){
$('#btnSubmit').dblclick(function(e){
e.preventDefault();
});
});