change image feedback message

change image feedback message

  
im trying to change the image inside feedback message with jquery but for some reason i dont know the image is not changed ,my code is:

<script type='text/javascript'>

    osjs('div.Feedback_Message_Success img').css('src','/img/xpto.png');


</script>

i think that jquery doesnt find the 
'div.Feedback_Message_Success img'
Hi Luis,

My first comment is that you're using the osjs namespace for javascript handling. While that may work, there's a reason why we encapsulate it inside a specific namespace, in this case osjs - it's because it might be changed in the future! I would avoid doing so in your eSpaces, and using more standard Javascript methods, like the document.getElementById and the like.
 

Regarding your issue here, however, I would assume that - if that piece of Javascript were to work - it would only work if the feedback message had already been created in the webpage's DOM, otherwise that might be the reason why it's not finding it. Another alternative - and one that happened to me - is that the execution of your javascript code

osjs('div.Feedback_Message_Success img')

returns an array, so the rest does nothing.

Try executing that on your browser and see what it returns. You might want to do

osjs('div.Feedback_Message_Success img')[0].src = '/img.xpto.gif';
osjs('div.Feedback_Message_Success img')[1].src = '/img.xpto.gif';

But preferably using the proper Javascript methods, and with some exception handling in case it doesn't find the feedback message...

I hope this helps - let us know how it goes.

Regards,

Paulo Tavares
In this particular case the img does not have id so the use of getElementById doesnt work.Do you have sure that the jquery function return an array?
Hi Luis,

No, I am not sure, what I said was that in my particular case when I tried to execute

osjs('div.Feedback_Message_Success img')

it it returned an array, so executing

osjs('div.Feedback_Message_Success img').css('src', 'xpto') 

would not do anything.


An easy way to go into it is to open the Firebug Console in Firefox - or the Script > Watch list, and type it there, to see what it returns.

Regards,

Paulo Tavares