0
Uncaught TypeError: Cannot read property 'value' of null Line: 1
<html> <head> <title>Page Title</title> </head> <body> <input type="text" name ="arguments" value="[[1,2,3,4],[1,2,3]]" id="aaa"/> <input type="button" value="Get Symmetric Diff" onClick="sym()" /> </body> </html> JS: var userInput = document.getElementById('aaa').value; function sym() { alert(userInput); }
4 Answers
+ 2
Where is the script tag included here? It looks to me like the script is running before the document has finished loading. For best results you should include your script at the very end of the body tag.
+ 2
Probably the best thing to do is more the assignment into the sym function.
+ 1
sorry i didnt say, i was using sololearn code playground, i dont need to include
0
Thanks James, that solved my problem