1

I want to make an autoDoubleClick function by only javascript.Example:

    var btn = document.getElementById("btn");
    btn.addEventListener("double",function(e){
        alert("Some thing");
    });

when we call function

autoDoubleClick(btn) 

so it will auto double click. Can you give me some ideal ??? (only javascript no jquery)

2
  • here is an answer : stackoverflow.com/questions/19479948/… Commented Aug 11, 2016 at 5:06
  • Are you trying to listen for a double click, or actually perform a double click? Commented Aug 11, 2016 at 5:09

1 Answer 1

1

The event name is dblclick. For triggering the event you can use the HTMLElement.prototype.dispatchEvent method:

btn.dispatchEvent(new Event('dblclick'));
Sign up to request clarification or add additional context in comments.

1 Comment

@Lucy What works on IE? :) That method is related to addEventListener. The method support on IE is similar to addEventListener. For supporting older versions of IE you can define helper functions. Here is a related question: stackoverflow.com/questions/17720431/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.