I have this code:

<td><apex:outputText value="{!e.p.Imagen_Producto__c}" escape="false"></apex:outputText></td> 

where the value "{!e.p.Imagen_Producto__c}" is equivalent to

<img src="/servlet/servlet.FileDownload?file=" alt="Foto" border="0"/>

Can I use JQuery to change the src value to



  • It is possible. However, is it possible for you to change the data source so that the img tag has the proper src value when the Imagen_Producto__c field is populated?
    – Mark Pond
    May 3, 2014 at 0:30

1 Answer 1


Some rough jQuery to do this:

    <apex:outputText value="{!e.p.Imagen_Producto__c}" escape="false"></apex:outputText>
        // retrieve the image element previous to this script element
        var imgTag = jQuery(document.currentScript).prev('img');

        // set the src attribute on the image element, prepended with "/b2b"
        jQuery(imgTag).attr('src', '/b2b' + imgTag.attr('src'));
  • Great Thanks Mark! If I put all of the jQuery above in a function what would be the best way to call it? I don't believe apex:outputText supports the onload attribute.
    – user5428
    May 4, 2014 at 1:53
  • No need for an onload, simply call it in an inline script block immediately after the element just as I did. What is your hesitation for not using the inline script tag?
    – Mark Pond
    May 4, 2014 at 18:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .