devsoft
devsoft

Reputation: 269

replace image (by clicking on image)

I want to do something like this. After click on image I want to choose another image for upload replace on server and dynamic display new one.

Thank you for any tip.

Upvotes: 0

Views: 462

Answers (3)

jfrubiom
jfrubiom

Reputation: 141

maybe you try using a upload form and send the upload to a hidden iframe... add a listener to this iframe to check when the file is complete upload... and retrieve the url of the new image and update the src of the img element

Upvotes: 0

jfrubiom
jfrubiom

Reputation: 141

You can try with this:

<img src="current_image.jpg" onclick="javascript:this.src='new_image.jpg';" />

Upvotes: 0

Chris Laplante
Chris Laplante

Reputation: 29658

Try something like this:

$("img").click(function(){
    $(this).attr("src", "http://example.com/someImage.gif");
});

Upvotes: 3

Related Questions