Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

153
Vistas
I used javascript/jquery to allow images on my website to popup, but it does not seem to work

When i click on an image, the popup does not seem to work, and there are no error messages as well. I searched google for examples but it doesnt work.

Here is my javascript code:

function eventHandlers(){
$(".img-thumbnail").click(togglePopup);}
function togglePopup(e){
var popup = document.getElementById("id_popup");

if (popup === null)
{
    
    popup = document.createElement("span");
    popup.id = id_popup;
    popup.setAttribute("class","image-popup");
    
    var thumbnail = e.target;
    var small_image = thumbnail.src;
    var large_image = small_image.replace("_small","_large");
    popup.innerHTML = '<img src=' + large_image + '>';
    
    thumbnail.insertAdjacentElement("afterend",popup);
} else
{
    $('#' + id_popup).remove();
}}

Code in the main file:

<figure>                 
     <img src="images/test.jpg" class="img-thumbnail" alt="Test" title="View larger image..."/>
     <span id="id_popup"
                    <span id="id_popup" class="image-popup"></span>
                    <figcaption>Standard Test</figcaption>
 </figure>

And my css code:

.image-popup {
border: 5px solid lightgrey;
margin-left: 25%;
margin-top: -60%;
height: 40vh;}

Additionally is there a way that i can modify my javascript file to allow the popup to close when clicked anywhere on the screen?

Help will be really appreciated. Thanks.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda