+ 3

How to use image as a button in Java Script

I need a image to act as a button, i.e: when i click the image it must say "hi".

27th May 2017, 9:10 AM
U L Knw Me soon😉😋
U L Knw Me soon😉😋 - avatar
9 odpowiedzi
+ 6
<img src="" id="mybutton" onclick="butClick();"> in css #mybutton{ cursor: pointer; } in js function butClick(){ //...code }
27th May 2017, 9:19 AM
MR Programmer
MR Programmer - avatar
+ 5
thanks @ Rintaro 😂
28th May 2017, 6:37 PM
U L Knw Me soon😉😋
U L Knw Me soon😉😋 - avatar
27th May 2017, 9:23 AM
_Retr0/-
_Retr0/- - avatar
+ 2
its done😂😂 hope u all like it😅 once again thanks for your help guyss!! https://code.sololearn.com/WcJBGTkIdlV0/?ref=app
27th May 2017, 10:40 AM
U L Knw Me soon😉😋
U L Knw Me soon😉😋 - avatar
+ 2
//HTML <img src="your own directory" onclick="newCall()"> //CSS img { cursor:pointer; max-width:100%; /*For centering an img*/ display:block; margin:auto; } //JS function newCall(){ //Alerts Hi! alert("Hi!"); //Prints/Puts String "Hi!" document.write("Hi!"); //Your Code: /* */ }
28th May 2017, 5:56 PM
riniwtz
riniwtz - avatar
+ 1
thanx guys!! i making one simple html program😅 its almost finished i will upload as soon as it is done😉
27th May 2017, 9:32 AM
U L Knw Me soon😉😋
U L Knw Me soon😉😋 - avatar
+ 1
simply to put img tag in A tag. <a><img src="" /></a>
28th May 2017, 6:48 PM
Bhupinder Singh
Bhupinder Singh - avatar
0
Google it :)
27th May 2017, 9:11 AM
Mateo Do
Mateo Do  - avatar
0
I will show u
27th May 2017, 9:15 AM
_Retr0/-
_Retr0/- - avatar