Skip to content
How do I display images on the click of a button?
Profile icon
KatieKiely

I've made this website and on the 'More Information' Page I want to display an image when the button is pressed but my javascript doesn't seem to be working. Any help would be appreciated!

You are viewing a single comment. View All
Profile icon
Grify

@Grify
To do this with css,

css:
img.active {display: block;}
img {display: none;}
js:
function showFieldImage(){
document.getElementById('imagefield').classList.add('active')
}

html:
Field

this works because it gives the image a class which makes it visible in css, showing the romance of these three beautiful languages!