0
<button onclick="myFunction()">Try it</button>

<script>
function myFunction() {
    document.getElementById("myImg").src = "hackanm.gif";
}
</script>

can you help me to correct the code. I would like to change the button to a image.
I would like to use javascript to change html

Kenny Chan
  • 75
  • 1
  • 5
  • https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/image or style.backgroundImage. – Lain Apr 30 '18 at 06:58
  • See updated list of duplicates - there are hundreds – mplungjan Apr 30 '18 at 07:02
  • Try it – Jukker Apr 30 '18 at 07:49
  • Don't forget the quotation mark "url('image...')" – Jukker Apr 30 '18 at 07:52

0 Answers0