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

107
Visualizações
Mi ventana emergente no se cierra cuando se hace clic en cualquier parte del fondo usando JavaScript/jQuery

Sé que hay muchas preguntas y respuestas relacionadas con esto, pero lo he intentado pero aún no puedo hacerlo. Por favor ayuda.

Aquí está mi código js:

 $(document).ready(clicklistener); // once ready, run clicklistener function function clicklistener() { $(".image-thumbnail").click(popup); // run popup function when ".image-thumbnail" is clicked} function popup() { var srcname = $(this).attr("src"); // get source image filename var newfile = srcname.replace("small", "large"); // replace with large img if ($(this).parent().children("span").children("img").hasClass("image-popup")) { // traverse the elements to check if the image popup already exists $(this).parent().children("span").remove(); // remove if it already exists } else { var printimg = "<span><img class=\"image-popup\"src=\"" + newfile + "\"></img></span>"; $(this).after(printimg); // create img if it doesn't exist }}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

No parece que tenga un evento definido para cerrarlo (a menos que haga clic en la ventana emergente). Entonces necesitas escribir uno:

 $(document).ready(function(){ $(".image-thumbnail").click(function(){ // allow for body.click to first hide any current images setTimeout(function(){popup($(this))}, 600)); // run popup function when ".image-thumbnail" is clicked }); function popup($ele) { var srcname = $ele.attr("src"); // get source image filename var newfile = srcname.replace("small", "large"); // replace with large img if ($ele.parent().children("span").children("img").hasClass("image-popup")) { // traverse the elements to check if the image popup already exists $ele.parent().children("span").remove(); // remove if it already exists } else { var printimg = "<span><img class=\"image-popup\"src=\"" + newfile + "\"></img></span>"; $ele.after(printimg); // create img if it doesn't exist } } $(window).click(function(){ $('.image-popup').remove() }); })
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