Answers for "how to display an image on button click in html"

6

img on click html

<!DOCTYPE html>
<html>
   <head>
      <title>HTML Image as link</title>
   </head>
   <body>
      The following image works as a link:<br>
      <a href="https://www.qries.com/">
         <img alt="Qries" src="https://www.qries.com/images/banner_logo.png"
         width=150" height="70">
      </a>
   </body>
</html>
Posted by: Guest on November-23-2019
0

button with image html

<style>
#wrapper{
  width:150px;
  height:150px;
  position:relative;
}

#btn{
  width:100%;
  height:100%;
  position:absolute;  
  background:none;
  padding:15px
}

#img{
  width:100%;
  height:100%;
}
</style>

<div id='wrapper'>
  <button id='btn'>Click me</button>
  <img id='img' src="https://images.unsplash.com/photo-1591160690555-5debfba289f0?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1000&q=80" alt="">
</div>
Posted by: Guest on September-25-2021

Code answers related to "how to display an image on button click in html"

Browse Popular Code Answers by Language