jQuery: replace image
I have this:
<div id="userPhoto">
<a href="profil.php?id=<?php echo $sid; ?>">
<img src="images/profilePhoto/thumbs/<?php if($vP["photo"]){ echo $vP["photo_thumb"]; }else{ echo "noPhoto_thumb.jpg"; } ?>" style="float: left; border: 2px solid #CCC; margin-开发者_如何学Goright: 5px; margin-left: 15px; margin-bottom: 2px; width: 44px; height: 48px;">
</a>
</div>
after upload, on success i wish to replace this image(noPhoto.jpg) with the new filename and show it, so a new image appears..
(that exists in newFilename variable)
How can i do this the most simple way?
$('#userPhoto').find('img').attr('src', ['/your/path/', newFilename].join(''));
In your success handler, set the image's source attribute:
$('#userPhoto img').attr('src', newFilename);
If you need more information about how to put this into a success handler, you'll need to show us some more code.
精彩评论