Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

155
Visualizações
how to make a mouse double click on a single click in plain javascript?

Hi i'm writing a plugin without JQuery .

On a single click the item.id is undefined and the link doesn't open. But after a second click the id is defined.

So i'm searching a workaround to make the mouse double click on a single click when clicking on this href link.

The div doesn't have a own default id.

Thanks for your help

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

This code triggers double click for every a tag that has a class of anchorLink when you singe click on them

I have explained it row by row in the code with comments on how it works

// Creating an event for double click (dblclick)
var event = new MouseEvent('dblclick', {
  'view': window,
  'bubbles': true,
  'cancelable': true
});

// get every a tag with class anchorLink and loop through them
document.querySelectorAll("a.anchorLink").forEach(anchorLink => {
  // add click event to it
  anchorLink.addEventListener('click', function (e) {
    // trigger double click event we created at top
    anchorLink.dispatchEvent(event);
  });
  
  // This is just to show that it triggers double click by single clicking
  // You dont need from here
  anchorLink.addEventListener('dblclick', function (e) {
    console.log(e.target.innerText);
  });
  //to here
  //
});
<a class="anchorLink" href="#" title="db2un_Fri Oct 18 16_38_15 2019.log" data-dojo-attach-point="linkColumnAnchor">db2un_Fri Oct 18 16_38_15 2019.log</a>
<br>
<a class="anchorLink" href="#" title="db2un_Fri Oct 18 16_38_15 2020.log" data-dojo-attach-point="linkColumnAnchor">db2un_Fri Oct 18 16_38_15 2020.log</a>

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda