[英]How to prepend text to this img src using JQuery
So basically I have this code and need to prepend some text to the src value. 所以基本上我有这段代码,需要在src值前添加一些文本。
<img src="/servlet/servlet.FileDownload?file=" alt="Foto" border="0"/></img>
Can I use JQuery to change the src value to 我可以使用JQuery将src值更改为
src="/b2b/servlet/servlet.FileDownload?file="
Thanks 谢谢
$('img[src^="/servlet/servlet"]').attr('src', function(_,src) {
return '/b2b' + src;
});
and image tags are self closing, so you should remove </img>
并且图片标签是自动关闭的,因此您应该删除
</img>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.