-2

I was wondering how to display an image inside of a button.

I have this code:

<input type="button" value="TEXT GOES HERE" onclick="showImage();"/>

And I wish to place an image within the button instead of text. I tried setting the value field to the path of the image:

<input type="button" value="this.src='Images/pickups.png'" onclick="showImage();"/>

but instead of displaying the image it simply displays the this.src... as text.

Jeff
  • 12,555
  • 5
  • 33
  • 60
ASA2k
  • 11
  • 5

1 Answers1

3

If you want a button, use button html tag, and inside put imgtag with src attribute pointing to your image url

<button type="button"  onclick="showImage();"><img src="favicon.ico"/></button>
Marko Mackic
  • 2,293
  • 1
  • 10
  • 19