Yo,
For the past weeks i try to simulate a double on my element but i can't find a solution. I know the click()
method exist but i can't find a smilary method for my problem. Thanks for your help
Yo,
For the past weeks i try to simulate a double on my element but i can't find a solution. I know the click()
method exist but i can't find a smilary method for my problem. Thanks for your help
You can trigger dblclick
event by using dispatchEvent
like this:
const event = new MouseEvent('dblclick');
document.getElementById('myId').dispatchEvent(event);
If you are using JQuery
, The second way is:
$('#myId').dblclick()
var button = document.getElementById("myButton");
button.addEventListener("dblclick", function() {
alert("Works!");
});
const event = new MouseEvent('dblclick');
button.dispatchEvent(event);
<button id="myButton">Test</button>