+ 3

how to take input from html and use it in js??

i have used the input tag and used it successfully outside of sololearn, but here in sololearn it is not working. I attached my code. hope you have suggestions? https://code.sololearn.com/W5zxbUE6DW5d/?ref=app

1st Sep 2019, 7:53 PM
Ahmad Ali
Ahmad Ali - avatar
4 Answers
+ 3
var text = document.getElementById("in").value; var rev_text = reverseString(text); these lines should be inside the event listener.
1st Sep 2019, 8:17 PM
Nidhi
+ 2
You need to add onsubmit attribute to the button and link it to a function. As I don't understand jquery I didn't fix it but I hope my answer guides u. If you need an example let me know and I will show u :)
1st Sep 2019, 8:17 PM
Minerals2016
Minerals2016 - avatar
+ 2
Minerals2016 I tried to put form and on submit but it didn't work here due to sololearn playground limitations.
1st Sep 2019, 8:43 PM
Ahmad Ali
Ahmad Ali - avatar
+ 2
nidhi it worked, thank you so much
1st Sep 2019, 8:45 PM
Ahmad Ali
Ahmad Ali - avatar