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

213
Visualizações
How I can rewrite this Jquery code into Vanilla JS

As I mentioned in the title, How can i rewrite this Jquery Code into Vanilla JS

Here's Jquery Code Example:

$(document).on('click', '.btn', function())

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

0

This is how VanillaJS snippet could look like

document.addEventListener('click', function (event) {
    if (!event.target.matches('.btn')) return;
    event.preventDefault();
    // Your code
}, false);

or if You prefer to attach click handler to specific element

var clickMe = document.querySelector('.click-me');
clickMe.addEventListener('click', function (event) {    // Dosomething... });
about 4 years ago · Juan Pablo Isaza Relatório

0

You can use the querySelector function which is similar to the $ in jQuery and add the desired listener using the addEventListener. If you want a list of all elements of the btn class you can use the querySelectorAll function.

See documentation here:

  • querySelector
  • querySelectorAll
  • addEventListener
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