0

Why won’t the comment box clear when submit is clicked?

https://code.sololearn.com/WPv3y6p3czzr/?ref=app When I used document.getElementById(‘commentBox’).value = “”; The comment box clears just fine after clicking submit. But when I use var comments = document.getElementById(commentBox).value; comments = “”; It doesn’t work. I thought these two were the same thing. Please help. I’m now sure what it is I’m missing here.

14th Nov 2018, 3:30 AM
Thomas Czernek
Thomas Czernek - avatar
1 ответ
+ 7
because comment is just a string, not the reference You have to write: document...(commentBox).value = "";
14th Nov 2018, 4:02 AM
Flandre Scarlet
Flandre Scarlet - avatar