0

A little help! Why is this an error?

var g = document.getElementById("box1"); function func() { g.style.background = "#FF00FF18"; } func();

31st Aug 2022, 2:03 PM
CuratoR
CuratoR - avatar
10 ответов
+ 4
You had some capitalised letter discrepancies. Check out my version of your code. https://code.sololearn.com/Wg01AIKYUVz3/?ref=app
31st Aug 2022, 2:32 PM
Ausgrindtube
Ausgrindtube - avatar
+ 4
Please LINK YOUR CODE so we can test it. What error do you get?
31st Aug 2022, 2:05 PM
Lisa
Lisa - avatar
+ 4
wrap your code inside an onload function window.onload = ()=>{ //your code }
31st Aug 2022, 2:08 PM
MATOVU CALEB
MATOVU CALEB - avatar
+ 2
AUSGRINDTUBE yeah your version does work but I still don't understand why mine doesn't 🤔
31st Aug 2022, 2:49 PM
CuratoR
CuratoR - avatar
+ 2
Percy Thethe check your first js line in js var g = document.getElementById("box1") //supposed to be like this var g = document.getElementById("Box1")
31st Aug 2022, 3:01 PM
MATOVU CALEB
MATOVU CALEB - avatar
+ 2
sendy kooper what isn't possible on your PC? If you don't have the same problem, can you please start your own thread/post/question?
1st Sep 2022, 2:05 PM
Ausgrindtube
Ausgrindtube - avatar
31st Aug 2022, 2:20 PM
CuratoR
CuratoR - avatar
+ 1
MATOVU I tried that it didn't seem to work 🤦🏽‍♂️
31st Aug 2022, 2:21 PM
CuratoR
CuratoR - avatar
+ 1
the error is at this line var g = document.getElementById("box1") Box1 is the id you used
31st Aug 2022, 2:32 PM
MATOVU CALEB
MATOVU CALEB - avatar
2nd Sep 2022, 1:22 PM
Abdul Samad
Abdul Samad - avatar