我有一个片段,我试图与之合作;我有几个产品,我抓住了源代码,将它拆分为“?”并将其放入数组中,然后用新链接替换“img.item-img”src。
但是,我没有使用循环或$('this')来区分它们的唯一性。所以如果我有三个项目,他们都获得第一个src代码。
<script>
$(document).ready(function() {
$("img.item-img").each(function() {
str = $("img.item-img").attr('src');
arr = str.split("?");
var new_link = arr[0];
$("img.item-img").attr('src', new_link);
});
</script>
你的问题是? – BenM
你的问题是什么?因为你说过你不用'$(this)',但为什么不呢? (这是我的问题......) –