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

285
Visualizações
Using Jquery, hide a div that is not existing yet, but will exist

I want to hide a div using JQuery on click event of another div. The problem is that the div that I want to hide is actually created only when I click on the existing div.

Let me explain with code example:

HTML:

<div class="first">I already exist and I create the second div when I am clicked</div>
<div class="second">I do not exist yet, I am created when first div is clicked</div>

The above is happening by another piece of code that another developer wrote.

I want to write another piece of code that will hide the second div when its created right after first div is clicked.

I do not have the permission to change the original dev's original code.

My JQuery that is not working:

$(".first").on("click",function() {
    $(".second").hide();
});
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You should use this, cause you have to make this delegate. explanation: https://api.jquery.com/on/

$("body").on("click", ".first",function() {
    $(".second").hide();
});
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