jquery,图像类型
我想使用jquery更改图像类型,例如:jquery,图像类型,jquery,image,Jquery,Image,我想使用jquery更改图像类型,例如: <img width="250" height="61" alt="Stack Overflow" src="http://sstatic.net/so/img/logo.png"/> 到 更改“.png:in.gif”(在本例中) 谢谢!这应该可以: $('img').each(function() { this.src = this.src.replace(/png$/, '.gif'); }); 这应该起作用: $(
<img width="250" height="61" alt="Stack Overflow" src="http://sstatic.net/so/img/logo.png"/>
到
更改“.png:in.gif”(在本例中)
谢谢!这应该可以:
$('img').each(function()
{
this.src = this.src.replace(/png$/, '.gif');
});
这应该起作用:
$('img').each(function()
{
this.src = this.src.replace(/png$/, '.gif');
});
尝试以下操作:(假设服务器上的所有.png
图像都具有等效的.gif
图像)
尝试以下操作:(假设服务器上的所有.png
图像都具有等效的.gif
图像)
我想他是在尝试更改链接中包装的图像。初始选择器应该是$('a img[src$=”.png“])我想他只是在复制源代码时犯了一个错误。我想他是在尝试更改链接中包装的图像。初始选择器应该是$('a img[src$=”.png“])我想他只是在抄写资料时犯了一个错误。
$('img[src$=".png"]').each(function(img) {
img.attr('src', img.attr('src').replace(/\.png$/, '.gif'));
});