jquery - javascript, fix all image src after change domain -


i changed domain of site domain1.com domain2.com

all images @ site this:

<img src="http://domain1.com/uploads/4353.jpg" /> <img src="http://domain1.com/uploads/54334.jpg" /> <img src="http://domain1.com/uploads/5345.jpg" /> 

i want change them to:

<img src="http://domain2.com/uploads/4353.jpg" /> <img src="http://domain2.com/uploads/54334.jpg" /> <img src="http://domain2.com/uploads/5345.jpg" /> 

i src of jquery this:

$('img').each(function() {      var oldsrc = $(this).attr('src');  }); 

how replace new src

$('img').prop('src', function () { return this.src.replace('domain1','domain2'); }) 

jsfiddle example


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

inno setup - TLabel or TNewStaticText - change .Font.Style on Focus like Cursor changes with .Cursor -