如何将字符串附加到图像网址?

时间:2015-05-27 01:48:29

标签: jquery html

我对提出这个问题感到非常愚蠢,但我一直在寻找答案,但无法找到我想要的代码。

我想做的就是在现有的图片网址上添加一个字符串。

在:

<div class="blog1"><img src="example.jpg"></div>

之后:<div class="blog1"><img src="example.jpg?Action=thumbnail&Width=80&Height=80"></div>

感谢您的帮助!!解决方案有效!!

1 个答案:

答案 0 :(得分:2)

$('.blog1 img').attr('src', function(){
  return this.src + "?Action=thumbnail&Width=80&Height=80";
});
相关问题