I tried any JS code - TypeError, another one - again Error! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
4 Answers
+ 4
You can only get the element by id once the DOM is fully loaded. Put the part inside of the onload function.
30th Jun 2023, 6:19 PM
Lisa
Lisa - avatar
+ 2
山 Zed Please send the code not images of it.
30th Jun 2023, 6:18 PM
Junior
Junior - avatar
+ 2
As already mentioned: Put let btn = document.getElementById("favorite-button-littleone-berryassort") inside the onload function.
1st Jul 2023, 7:26 AM
Lisa
Lisa - avatar
1st Jul 2023, 6:35 AM
山 Zed
山 Zed - avatar