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

292
Views
Image Zoom Magnifying Glass Effect with CSS3 and jQuery - with multiple image

html codes for magnify

here is the javascript

$(document).ready(function()
        {
            var sub_width = 0;
            var sub_height = 0;
            $(".large").css("background","url('" + $(".small").attr("src") + "') no-repeat");

            $(".zoom-area").mousemove(function(e){
                if(!sub_width && !sub_height)
                {
                    var image_object = new Image();
                    image_object.src = $(".small").attr("src");
                    sub_width = image_object.width;
                    sub_height = image_object.height;
                }
                else
                {
                    var magnify_position = $(this).offset();

                    var mx = e.pageX - magnify_position.left;
                    var my = e.pageY - magnify_position.top;
                    
                    if(mx < $(this).width() && my < $(this).height() && mx > 0 && my > 0)
                    {
                        $(".large").fadeIn(100);
                    }
                    else
                    {
                        $(".large").fadeOut(100);
                    }
                    if($(".large").is(":visible"))
                    {
                        var rx = Math.round(mx/$(".small").width()*sub_width - $(".large").width()/2)*-1;
                        var ry = Math.round(my/$(".small").height()*sub_height - $(".large").height()/2)*-1;

                        var bgp = rx + "px " + ry + "px";
                        
                        var px = mx - $(".large").width()/2;
                        var py = my - $(".large").height()/2;

                        $(".large").css({left: px, top: py, backgroundPosition: bgp});
                    }
                }
            })
        })

in the 2nd image the 'magnify' function is not working , using the same class but 2nd image does not have the function.

what i wanted to do is have magnify function on multiple image

codepen : https://codepen.io/wavyblues/pen/PoKoVJM

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!