Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

149
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!