CodeNewbie Community 🌱

Amanda Lynn
Amanda Lynn

Posted on

Dark Mode / Light Mode

I recently learned how to add a button that invokes dark/light mode on my websites.

We went over .getElementByID() in class and I said to myself, "I can do this, no big." Until I realized my website was split into multiple divs and I used classes instead of id's to style.

It took me a minute (i.e. a long time) to figure out how to use .getElementsbyClassName() , since it returns an array and we hadn't learned that yet.

I had to research what an array was and how to do for loops. Although, it took some time, I'm proud to say it worked out.

The feeling of accomplishment is always especially satisfying after I've struggled to achieve the result.

Looking forward to future successes.

Top comments (3)

Collapse
 
andrewbaisden profile image
Andrew Baisden

Well done I added Dark Mode / Light Mode to my latest website too.

Collapse
 
shriekdj profile image
Shrikant Dhayje

well done btw 👍

Collapse
 
shriekdj profile image
Shrikant Dhayje • Edited

i had the same experience while struggling to compiler in college because that mandatory compiler was Turbo C.