0

What is wrong with this code?

let demo = document.getElementById("p-el").innerHTML console.log(demo) I'm getting a "cannot read property null of InnerHTML

9th Apr 2022, 9:53 AM
Yusuf Muhammad
Yusuf Muhammad - avatar
3 Answers
+ 1
Put the code right after the html code in the body tag with the script tag, the js code is being run before the html gets loaded.
9th Apr 2022, 10:04 AM
Jalaj Madaan
Jalaj Madaan - avatar
0
Thanks it worked.. But is this peculiar to SoloLearn ide how that's how it generally is?
9th Apr 2022, 10:10 AM
Yusuf Muhammad
Yusuf Muhammad - avatar
0
Well I don't know about that, I've never really done a js project outside of sololearn but I've definitely seen a lot of complaints on that outside of sololearn so maybe.
9th Apr 2022, 10:11 AM
Jalaj Madaan
Jalaj Madaan - avatar