+ 2

Why doesn't this work?

It says 'Can not read property value of null'. https://code.sololearn.com/W2CGn0yTNnC7/?ref=app

20th Oct 2019, 7:27 PM
Rishan [da_coder, semi-active]
Rishan  [da_coder, semi-active] - avatar
3 ответов
+ 1
It is happening because js is loading first after that html. Change with this. It will work fine. function removeSpaces() { var s = document.getElementById("input"); var sv = s.value; var l = sv.length; var r = document.getElementById("result"); var p; for (var i = 0; i <= l; i++) { p = sv.replace(" ", ""); } r.value = p; }
20th Oct 2019, 7:32 PM
A͢J
A͢J - avatar
+ 4
Nevermind
21st Oct 2019, 1:32 AM
Rishan [da_coder, semi-active]
Rishan  [da_coder, semi-active] - avatar
+ 3
Can you put it into a code?
21st Oct 2019, 1:30 AM
Rishan [da_coder, semi-active]
Rishan  [da_coder, semi-active] - avatar