0

Plz help someone quick.

I was writing code in web. I wrote it on sololearn website desktop mode and the code was working fine. But the same code is not working on mobile.can some one explain why? Code was getting value of input tag of html using javascript. Eg:- <input type="text" id="field" value="this is text field"> Js- Let data = document.getElementById("field").value; console.log(data); Plz someone explain this asap

21st Jun 2022, 4:01 AM
Avinash
Avinash - avatar
5 odpowiedzi
+ 3
If you mean this code: https://code.sololearn.com/WmUtUFCmeECW/?ref=app Put the JS scripts in a script tag before </body> in HTML tab https://www.sololearn.com/post/90825/?ref=app
21st Jun 2022, 4:27 AM
Gordon
Gordon - avatar
+ 3
This platform automatically include the scripts in the <head> Because your getElement function executes before the DOM is created, they returned null.
21st Jun 2022, 4:55 AM
Gordon
Gordon - avatar
+ 1
Did you uppercase the “let” keyword? JS is case-sensitive.
21st Jun 2022, 4:09 AM
Jeremias
+ 1
Gordon hey thanks for helping me out. I thought this platform is automatically including script tag and stylesheet that's why i didn't included script tag in html code. Actually website playground was working fine without even including script tag in html.
21st Jun 2022, 4:48 AM
Avinash
Avinash - avatar
0
Jeremias thanks for answering but was not the issue
21st Jun 2022, 4:44 AM
Avinash
Avinash - avatar