Wednesday, 18 September 2013

How to change image .attr("src") using jquery

How to change image .attr("src") using jquery

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 create
correctly but I cannot modify the image in the last line.
What is wrong here?
..... // 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
});

No comments:

Post a Comment