如何在某些 div 中将 src 更改为 data-src

How to change src to data-src in certain div

有问题的页面:https://373834.myshoptet.com/80-104-cm/

页面上的JS代码:

<div class="slider-in-80-104-cm">&nbsp;</div>
<script>$(".slider-in-80-104-cm").load("/ #products-27")</script>

从以下位置加载选项卡内容:https://373834.myshoptet.com - ID #products-27 下的选项卡(参见页面源代码)

在 Shoptet.cz 中可以将 TITLE PAGE 中的产品添加到 bs 选项卡 - 请参阅标题页。我需要此产品的分类(如 80-104 厘米等)

我使用 jquery $从标题页选项卡加载内容到某些页面(产品类别),但在类别页面上仅加载前 4 个带有图像的产品,但下一个产品加载时没有图像。

如果我在 shoptet admin 中更改产品的位置,总是不会在第五个和下一个产品上显示图像。

我需要更改 src 做 data-src,因为在某些图像中 shoptet 加载 src,但我需要在 data-src.[=16 中显示真实图像=]

<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-src="https://cdn.myshoptet.com/usr/373834.myshoptet.com/user/shop/detail/682_ergonomicke-nositko-fidella-fusion-baby-size-cubic-lines-rustred.jpg?5f592575" alt="Ergonomické nosítko Fidella Fusion BABY SIZE - Cubic Lines Rustred" data-micro-image="https://cdn.myshoptet.com/usr/373834.myshoptet.com/user/shop/big/682_ergonomicke-nositko-fidella-fusion-baby-size-cubic-lines-rustred.jpg?5f592575">

我使用了这里的许多 jquery 代码,但没有任何功能。谢谢。

试试这个...

//lets say your image looks like this, give it an id
// <img src="something" id="image"/>

//to give it a data attribute you do this

setTimeout(function(){
  $('.slider-in-80-104-cm .image img').each(function(){ 
    $(this).attr('src', $(this).attr('data-src'));
  });
},1000);