The script does not work in the mobile version ( on mobile devices, the template is adaptive ). There are thumbnails that when clicked are displayed in another div 'e with <img ID=main_img . In the mobile version, when you click on a thumbnail, the first image is selected, but not the desired one.

 $('.preview a').click(function() { way = $(this).children().attr("src"); console.log(way); $('#main_img').attr('src', way); function_name(); return false; }); 

At the same time, there is no problem in the desktop version. Can fancybox affect? Help to understand plz.

    2 answers 2

     $('.preview a').each(function(){ //Π½Π°ΠΉΡ‚ΠΈ всС вхоТдСния ΠΈ для ΠΊΠ°ΠΆΠ΄ΠΎΠ³ΠΎ $(this).on("click tap", function() { // Π½Π° ΠΊΠ»ΠΈΠΊ Π½Π°Π·Π½Π°Ρ‡ΠΈΡ‚ΡŒ... // PUT YOUR CODE HERE ;) } }); 

    although here https://stackoverflow.com/questions/6235794/jquery-mobile-for-every-live-tap-event-should-there-be-an-equivalent-click-even people write that with "click tap "may be a problem and suggests using a third-party plugin.

      Check this code

       $(document).ready(function(){ $('.preview a').on("click touchstart", function() { way = $(this).children().attr("src"); console.log(way); $('#main_img').attr('src', way); function_name(); return false; }); }); 
      • This option does not work ... - cooledit
      • This is the same thing as the author of the question - Yuri
      • I updated the code, check it out now - L. Vadim
      • Checked, does not work .. - cooledit
      • try to wrap all the document read - L. Vadim