0

How I can use html button with a javascript code ex: button click--> alert("...")

help

20th Aug 2018, 6:04 PM
Raitovin
Raitovin - avatar
7 Answers
+ 3
Full code: <!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> <button onclick="alert('This works!')">Click here</button> </body> </html>
20th Aug 2018, 6:31 PM
Russ
Russ - avatar
+ 1
HTML: <button onclick="click()"> JS: function click() { alert("...") }
20th Aug 2018, 6:14 PM
ReimarPB
ReimarPB - avatar
+ 1
onclick event: <button onclick="alert('...')">Click me</button>
20th Aug 2018, 6:16 PM
Zguillez
Zguillez - avatar
+ 1
To be fair, I'm getting the same issue. Can someone better than me show what's up? https://code.sololearn.com/WdBBSZY8C80r/?ref=app Edit: it seems the choice of the function name 'click' stops it being executed (because it's a keyword?). Changing the function name gets it to work.
20th Aug 2018, 7:22 PM
Russ
Russ - avatar
0
ok thanks
20th Aug 2018, 6:15 PM
Raitovin
Raitovin - avatar
0
but I have use your code but their isn't reaction
20th Aug 2018, 6:22 PM
Raitovin
Raitovin - avatar
0
J'ai fait ça : html: <button onclick="click ()"> js: function click (){ alert ("..."); } mais ça ne fonctionne pas
20th Aug 2018, 7:08 PM
Raitovin
Raitovin - avatar