JQuery: Appending Attribute Value to Each Element
Try:
$("img").each(function () {
var originalSrc = $(this).attr('src');
$(this).attr('src', 'http://www.domain-name.com/' + originalSrc);
});
Even less work with (compare http://api.jquery.com/attr/) :
$("img").attr('src', function(i, val){
return 'http://www.domain.com/' + val;
});
$("a").attr('href', function(i, val){
return 'http://www.domain.com/' + val;
});
Greets