Trying to call a function called "clear()" in javascript but it won't work, the function works when put into the console but won't when I click the button.
Asked
Active
Viewed 260 times
-3
-
2add the full code – Sagar V Mar 28 '17 at 10:18
-
You want to show a [MCVE] that demonstrates your problem. – pvg Mar 28 '17 at 10:19
-
Generally when asking "why doesn't this code work" it's a good idea to show said code. – George Mar 28 '17 at 10:19
1 Answers
1
Its a problem with your function name, try change it to clearMe()
Use the link below, the code works fine..
https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_onclick
..if you change the function name to clear
it does not.

J Foley
- 1,038
- 1
- 17
- 30
-
Thought it might have been a reserved word in javascript, doesn't look to be but looks like it still causes issues.. http://stackoverflow.com/questions/7165570/is-clear-a-reserved-word-in-javascript – J Foley Mar 28 '17 at 10:29
-