+ 3
Why is button onclick saying function does not exist?
Here is my code. Please copy the code and paste it and run the code to check the problem. Please tell me why this is happening. My code says the function event() does not exist even though i defined the function. <!DOCTYPE html> <html> <head> <script type=text/javascript> function event() { alert("hello"); } </script> <title>Page Title</title> </head> <body> <button onclick= "event()">hello</button> </body> </html>
3 Respostas
+ 4
event is a Keyword in js try using different name it will work 👍
https://code.sololearn.com/WWPSTx81wJyj/?ref=app
+ 2
Event is Js Syntax in javascript you can't name it as function like you can't make variable as var,let or const
So like this you can define the inbuilt javascript function
0
event is reserved