Last active
April 7, 2017 09:21
-
-
Save daylik/5a8263c4c0f0a02308c2e386a379086c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function find_replace(selector, attr, find, replace, v){ | |
v = {}; | |
$(selector).each(function(){ | |
v.img_src = $(this).attr(attr); | |
v.out = v.img_src.replace(find, replace); | |
$(this).attr(attr, v.out); | |
}); | |
} | |
find_replace('img', 'src', /site.ru/i, '127.0.0.1'); | |
//<img src="http://site.ru/img.jpg" /> | |
//to | |
//<img src="http://127.0.0.1/img.jpg" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment