0

This js code using for making zooming on a click picture. But i don't get clicked image src. Its working fine in exemple, but unfortunately not in my site. Why may it happens?

Example with working code https://codepen.io/Evangelion_01/pen/zEoKaR

code in my site, js file:

  $(document).ready(function() { 

        $(".pro02_01_box").click(function(){    //.pro02_01_box class of that image
            let img = $(this);  //get cklicker img url
            let src = img.attr("src"); //wrote the value into a variable
            $("body").append("<div class='popup'>"+ 
                             "<div class='popup_bg'></div>"+ 
                             "<img src='"+src+"' class='popup_img' />"+
                             "</div>");
            $(".popup").fadeIn(200); 
            $(".popup_bg").click(function(){    затемненный фон    
                $(".popup").fadeOut(200);   
          setTimeout(function() {   
                  $(".popup").remove(); 
                }, 200);
            });
        });

    });

Answer in browser console:

Indefined in answer

홍기석
  • 1
  • 1
  • where is `.pro02_01_box` ??? – Devsi Odedra Aug 08 '19 at 09:16
  • Looks like: `let img = $(this); let src = img.attr("src");` isn't hitting what you want it to - what does dev tools say - set a break-point there when you run it. – Mike Brockington Aug 08 '19 at 09:18
  • Please provide your *full* code (preferably without non-English comments) – GalAbra Aug 08 '19 at 09:21
  • Thank you for your attention very much! First comment was right, i just put wrong class in js code. It was class from div with that img, not class from img tag. Thats why js wrote in valuable not img src, just part of another code. lol... – 홍기석 Aug 09 '19 at 02:44

1 Answers1

0

$this seems to cause problem.

Already solved @ Using jQuery .attr or .prop to set attribute value not working