Wednesday, June 5, 2024
 Popular · Latest · Hot · Upcoming
109
rated 0 times [  116] [ 7]  / answers: 1 / hits: 161490  / 11 Years ago, wed, september 18, 2013, 12:00:00

I need to change the src for an html image tag from relative to absolute url.



I am using the following code. urlRelative and urlAbsolute are created correctly but I cannot modify the image in the last line.



What could be wrong wrong in my script?



..... // other code here

request.done(function(resp) {
var imgTags = $('img', resp).each(function() {
var urlRelative = $(this).attr(src);
var urlAbsolute = self.config.proxy_server + self.config.location_images + urlRelative;
$(this).attr(src).replace(urlRelative, urlAbsolute); // problem here
});

More From » jquery

 Answers
10

Try like this



$(this).attr(src, urlAbsolute)

[#75627] Tuesday, September 17, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jaydon

Total Points: 651
Total Questions: 103
Total Answers: 100

Location: Norway
Member since Mon, May 23, 2022
2 Years ago
;