Replace img path jquery

前端 未结 6 1020
后悔当初
后悔当初 2021-01-26 18:48

I am trying to replace an img path in jquery (injecting into a remote page)

replace example.com/thumbs

with ex

6条回答
  •  野性不改
    2021-01-26 19:31

    var oldSrc = 'http://example.com/smith.gif';
    var newSrc = 'http://example.com/johnson.gif';
    $('img[src="' + oldSrc + '"]').attr('src', newSrc);
    

    This is what you wanna do:

提交回复
热议问题