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

196
Views
jQuery elevateZoom work only when I put an alert() before

I have this code to launch jQuery elevateZoom but, only works if I put an alert() before.

I have already try with/without load() function.

jQuery(document).ready(function($){
    alert("Hi");
    $("#sh-product-main-image").load(function(){
        $(this).elevateZoom({
            zoomType: "inner",
            debug : true,
            cursor: "crosshair", 
            zoomWindowFadeIn: 500,
            zoomWindowFadeOut: 500
        }); 
    }); 
});

This is another variation of the code I have tried:

jQuery(document).ready(function($){
    alert("Hi");
    $("#sh-product-main-image").elevateZoom({
        zoomType: "inner",
        debug : true,
        cursor: "crosshair", 
        zoomWindowFadeIn: 500,
        zoomWindowFadeOut: 500
    }); 
});
about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

This is because $(document).ready() happens when the DOM is loaded, not when all the images are loaded. The alert causes a delay and allows time for the image to be loaded.

The following should work:

$(window).on("load", function() {
    $("#sh-product-main-image").elevateZoom({
        zoomType: "inner",
        debug : true,
        cursor: "crosshair", 
        zoomWindowFadeIn: 500,
        zoomWindowFadeOut: 500
    }); 
});
about 4 years ago · Santiago Trujillo Report

0

I think elevateZoom plugin requires only DOM to be fully loaded in order to work properly, not the Page load! (DOM load is normally recommended over Page load!)

I think the code below would be enough:

$(function() { /* Executed after DOM did load */

  $("img#sh-product-main-image").elevateZoom({
    zoomType: "inner",
    debug : true,
    cursor: "crosshair", 
    zoomWindowFadeIn: 500,
    zoomWindowFadeOut: 500
  });

});
about 4 years ago · Santiago Trujillo Report
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!