+ 1

Adding a javascript 'alert' to a html 'button'?

On one of the projects that I have started has me adding an alert command to a button, and I can't figure it out. (48 hours in.) https://code.sololearn.com/Wk4fPV18dXr0/?ref=app

3rd Jul 2018, 10:49 PM
Icarus8
Icarus8 - avatar
4 Answers
+ 6
<button onclick="alert('Hello world')"> Start </button>
3rd Jul 2018, 10:54 PM
᠌᠌Code X
᠌᠌Code X - avatar
+ 1
Note: You can change the name of workButton() HTML: <button onClick=“workButton()”>Start</button> JavaScript: function workButton(){ alert(“Hello”) }
4th Jul 2018, 12:25 AM
AquA217
AquA217 - avatar
+ 1
How about like this. Html button JavaScript function https://code.sololearn.com/WQyUaQHeLLuB/?ref=app
4th Jul 2018, 1:47 AM
Timothy Arundell
0
Hi Icarus8, Maybe I popped into your code at the wrong moment, but it doesn't look like anything is happening. You've got a button, but no JavaScript. Maybe start here and see how you get along? https://www.w3schools.com/js/tryit.asp?filename=tryjs_alert I hope this helps! :)
3rd Jul 2018, 10:55 PM
Janning⭐
Janning⭐ - avatar