show image javascript code example
Example 1: show image javascript
HTML:
Show image
JavaScript:
document.getElementById("showImage").onclick = function() {
document.getElementById("theImage").style.visibility = "visible";
}
CSS:
#theImage { visibility: hidden; }
Example 2: show image javascript
JS:
function setImageVisible(id, visible) {
var img = document.getElementById(id);
img.style.visibility = (visible ? 'visible' : 'hidden');
}
HTML:
Then, your links would be:
show image
hide image
CSS:
#theImage { visibility: hidden; }