Replace img path jquery

前端 未结 6 997
后悔当初
后悔当初 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:19

    Step 1: script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js">
    Step 2:

        $(document).ready(function(){
             $('img').each(function() {
                   $(this).attr('src', $(this).attr('src').replace('thumbs', 'images')); 
                   console.log('Latest image link ' + $(this).attr('src'));
               });
          });
    

提交回复
热议问题