Answers for "javascript show image src"

21

set image src in javascript

//change image src
document.getElementById('myImageID').src="images/my_other_image.png";
Posted by: Guest on July-31-2019
0

show image javascript

JS:
function setImageVisible(id, visible) {
    var img = document.getElementById(id);
    img.style.visibility = (visible ? 'visible' : 'hidden');
}

HTML:
<img id="myImageId" src="yourImage.png">
Then, your links would be:
<a href="javascript:setImageVisible('myImageId', true)">show image</a>
<a href="javascript:setImageVisible('myImageId', false)">hide image</a>

CSS:
#theImage { visibility: hidden; }
Posted by: Guest on January-30-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language