+ 3

why "addEventListener()" is not working in Sololearn App

https://code.sololearn.com/WA236a9A12a2/#

18th Dec 2020, 1:28 PM
Alok Yadav
Alok Yadav - avatar
7 Answers
+ 4
The link opens using SoloLearn app, does not open using web browser. In short, addEventListener was invoked before the DOM was completely constructed. The element is not yet there, and thus you get the error message. You can wrap the JS code in a window load event handler. window.onload = () => { // your code here }
18th Dec 2020, 1:47 PM
Ipang
+ 4
You will find the answer in this post 👍 https://www.sololearn.com/post/90825/?ref=app
18th Dec 2020, 1:38 PM
Ipang
+ 2
Thanks 👍 but it works on web version of sololearn
18th Dec 2020, 1:45 PM
Alok Yadav
Alok Yadav - avatar
+ 2
I'm guessing there's a difference in how script is processed between SoloLearn app and web.
18th Dec 2020, 1:59 PM
Ipang
+ 2
Thanks a lot bro 💚💚 it's working now👏👏
18th Dec 2020, 2:19 PM
Alok Yadav
Alok Yadav - avatar
+ 1
You have a try that adding event listener on the html page within script tags. That works for me😊
20th Dec 2020, 12:50 PM
DINESH
DINESH - avatar