Show/hide image with JavaScript

后端 未结 6 645
抹茶落季
抹茶落季 2020-12-08 15:17

I have an HTML page with an image that I set to be invisible by CSS visibility: hidden. I want to make a link called \"Show image\", so that when I click on it,

6条回答
  •  一生所求
    2020-12-08 15:27

    It's pretty simple.

    HTML:

    
    Show image
    

    JavaScript:

    document.getElementById("showImage").onclick = function() {
        document.getElementById("theImage").style.visibility = "visible";
    }
    

    CSS:

    #theImage { visibility: hidden; }
    

提交回复
热议问题