-1
<img id="Preview"  style="width: 150px; height: 200px;"/>

<script>
    $("#Preview").attr('src', "pic1.png");
</script>

This shows an image sometimes, but after I refresh my page this image will disappear. I put this line of code into the script:

$("#Preview").attr('src', "pic1.png?timestamp="+new Date().getTime());

But it doesn't help! Can you please help me to solve this?

2

2 Answers 2

2
jQuery(document).ready(function($){
   $("#Preview").prop("src", "pic1.png?timestamp="+new Date().getTime());
});

Note: The image URL should be correct, try to give full URL.

Sign up to request clarification or add additional context in comments.

Comments

1
  1. did you use jQuery? if not, you can try like this:

img = document.getElementById('yourID')
img.src = "your image url"

  1. make sure the image path is work.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.