0

Why won't this button call my javascript function?

https://code.sololearn.com/Wf7ISxbYbPg8/?ref=app

3rd Apr 2019, 4:10 PM
Augustine
Augustine - avatar
5 odpowiedzi
+ 2
try is not a good name! Change it, and it works ;-)
3rd Apr 2019, 5:28 PM
PapaBT
PapaBT - avatar
+ 2
You can't use names like : try , alert ,function , prompt etc as a function name
4th Apr 2019, 7:11 PM
Mario
Mario - avatar
+ 1
Yes indeed, try is reserved, in your SoloLearn it highlights purple, choose a correct name and it changes to white Use this <button onclick ="trybut()">BUTTON</button> and don't forget to change the name of your function to trybut() too
3rd Apr 2019, 5:46 PM
Robin R.
Robin R. - avatar
+ 1
try has a purpose in JavaScript https://www.w3schools.com/js/js_errors.asp
3rd Apr 2019, 5:47 PM
Robin R.
Robin R. - avatar
+ 1
Thanks guys
5th Apr 2019, 10:54 AM
Augustine
Augustine - avatar