---
title: "How to display image after clicked button using JavaScript?"  
description: "How to display image after clicked button using JavaScript?"  
author: "Ravi Vishwakarma"  
published: 2021-07-19  
canonical: https://answers.mindstick.com/qa/93781/how-to-display-image-after-clicked-button-using-javascript  
category: "web application"  
tags: ["web application development", "javascript", "html5", "css cascading style sheets"]  
reading_time: 1 minute  

---

# How to display image after clicked button using JavaScript?

How to display [image](https://www.mindstick.com/blog/216/i-want-to-display-images-into-to-datagridview-one-by-one-taking-image-url-from-database-field) after clicked [button](https://www.mindstick.com/articles/63/how-to-add-button-in-datagridview-in-csharp-dot-net) using [JavaScript](https://www.mindstick.com/articles/1530/design-a-simple-stylish-calculator-using-html-css-and-javascript)?

## Answers

### Answer by Ethan Karla

```
<!DOCTYPE html>
<html lang='en' xmlns='http://www.w3.org/1999/xhtml'>
<head>
    <meta charset='utf-8' />
    <title></title>
    <style>
    img{
        box-sizing:border-box;
        width:40%;
        height:auto;
        display:none;
        padding:5px;
        }
        button {
            width:100px;
            height:30px;
        }
    </style>
</head>
<body>
    <img src='wood2.jpg' id='image'/>
    <button onclick='showImage()'>Show Image</button>
    <button onclick='hideImage()'>Hide Image</button>
    <script>
        function showImage() {
            document.getElementById('image').style.display = 'block';
        }
        function hideImage() {
            document.getElementById('image').style.display = 'none';
        }
    </script>
</body>
</html>
```

\

### Answer by user

This in answers test on This in answers test on This in answers test on This in answers test on


---

Original Source: https://answers.mindstick.com/qa/93781/how-to-display-image-after-clicked-button-using-javascript

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
