Why this simple form submit has js uncaught type error show on the console? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

Why this simple form submit has js uncaught type error show on the console?

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

13th Apr 2017, 1:50 PM
Calviղ
Calviղ - avatar
2 Answers
+ 10
Place your JS code inside script tag in body or onload method of body and it will work. Currently, your JS code is executing even before the HTML is rendered. That's why throwing error.
13th Apr 2017, 1:53 PM
Ashwani Kumar
Ashwani Kumar - avatar
+ 4
@Ashwani thank you so much. You really saved my day. 🤗
13th Apr 2017, 2:00 PM
Calviղ
Calviղ - avatar