When write: $('#' + id + ' img').attr("src", "images/favorites.png"); … it works. alert (msg) says "favorites".
There must be something wrong with msg. If the variable is defined before var favimg = "favorites"; and I insert favimg it works just fine. What could be wrong with msg? msg is what I echo back in my PHP code. I don't know if this is the appropriate way. On 22 Sep., 13:34, MorningZ <[EMAIL PROTECTED]> wrote: > "But the image isn't replaced correctly" > > Perhaps try changing this line instead > > $('#' + id + ' img').attr("src", "images/"+msg+".png"); > > There's no reason why that (or your line for that matter) wouldn't > work as long as the selector finds something and the value of the > "src" is a valid path on your server