Reputation: 113
I want an event to be triggered when the image is clicked, but I cannot figure out how to make that happen. Is it possible for an event to be triggered when an image is clicked?
<form>
<input type="button" name="button" value="Download" onclick="passWord()" class="button"/>
</form>
jsfiddle: https://jsfiddle.net/29mf5wf9/
Upvotes: 0
Views: 3009
Reputation: 14810
You can use image
instead of button
for input type
. It will still be a button.
HTML
<input type="image" src="image/path" name="button" value="Download" onclick="passWord()" class="button"/>
According to the docs
The
<input type="image">
is a graphical submit button.
See the updated fiddle with a javascript function working..
Upvotes: 3
Reputation: 994
Here you can find the information: http://www.w3schools.com/tags/att_input_src.asp
<input type="image" src="your_image.png" name="button" value="Download" alt="Download" onclick="passWord();" class="button" width="your_image_width" height="your_image_height">
Upvotes: 1
Reputation: 11
You need to specify image in the type.
<form>
<input type="image" src="http://cdn.sstatic.net/stackexchange/img/logos/so/so-logo.png" name="button" value="Download" onclick="passWord()" class="button"/>
</form>
Upvotes: 1